1. Go to this page and download the library: Download jiannius/filesystem 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/ */
use Jiannius\Filesystem\Models\File;
// From an uploaded file
$file = File::storeUpload($request->file('photo'), 'avatars', 'public');
// From a YouTube URL — fetches title + thumbnail via noembed.com
$video = File::storeYoutube('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
// From a remote image URL — downloads, captures dimensions
$image = File::storeImageUrl('https://example.com/photo.jpg');
// Returns a signed URL valid for the configured TTL (default 7 days, min.)
$file->getImageUrl();
// Custom TTL in days
$file->getImageUrl([], 30);
// No expiry
$file->getImageUrl([], 0);
// With Glide transformations
$file->getImageUrl(['w' => 400, 'h' => 400, 'fit' => 'crop']);
// app/Models/File.php
namespace App\Models;
class File extends \Jiannius\Filesystem\Models\File
{
public function organization()
{
return $this->belongsTo(Organization::class);
}
public function auth(): bool
{
return $this->user_id === auth()->id();
}
}