1. Go to this page and download the library: Download sextanet/laravel-files library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sextanet / laravel-files example snippets
use SextaNet\LaravelFiles\HasFiles; // 👈 1. Import
class YourModel extends Model
{
use HasFiles; // 👈 2. Use it
}
$uploaded_file = request()->your_file; // let's supose you have "a_video.mp4"
$file = $user->addFile($uploaded_file); // using your default disk from config/filesystems.php
$file = $user->addFile($uploaded_file, 'destination', 'my_file'); // will store on destination/my_file.mp4
// Don't forget to import the LaravelFiles facade
use SextaNet\LaravelFiles\Facades\LaravelFiles;
// Set temporary URL for 120 minutes
LaravelFiles::setTemporaryUrlMinutes(120);
$temporary_url = $file->getTemporaryUrl(); // Will return 120 minutes
// Don't forget to import the LaravelFiles facade
use SextaNet\LaravelFiles\Facades\LaravelFiles;
// Store on another disk, like s3
LaravelFiles::setDisk('s3');