This is how you can upload your file with optional options, and retrieving it whenever you want.
1// Uploading file 2// function upload(UploadedFile $file, array $options = []) 3$file = upload($request->image); 4 5// Retrieving file 6// getUploaded(string $code); 7$file = getUploaded('5e63885fa771d1.12185481920ncF3...'); 8 9// Information 10echo $file->hash; // File's Hash11echo $file->name; // File's Name12echo $file->path; // File's Path13echo $file->size; // File's Size in Bytes14echo $file->readableSize(); // File's Size [B, KB, MB, ...] (1000)15echo $file->readableSize(false); // File's Size [B, KiB, MiB, ...] (1024)16echo $file->extension; // File's Extension17echo $file->mime; // File's MIME18echo $file->visits; // File's visits (Visitable File)19echo $file->url; // File's URL20 21$user = $file->uploader; // Upload Object
Option | Description |
---|---|
visitable (Boolean) |
Visits Counter. |
private (Boolean) |
Only Permitted Users. |
directory (String) |
The uploading path. |
thumbnail (Array) |
Creating thumbnail automatically, but there is some keys you should understand it ratio Boolean width Integer|NULL height Integer|NULL. |
This is how you can upload your image and generate thumbnail for it too.
1$file = upload($request->cover, [ 2 'directory' => '/videos', 3 'thumbnail' => [ // thumbnail option 4 'ratio' => true, // with aspect ratio 5 'width' => 500, // with 500px width 6 'height' => null 7 ], 8]); 9 10echo $file->url; // File's URL11echo $file->thumbnail->url; // File's Thumbnail URL
This feature to permitting & forbidding users and give expiration date for this permitting.
1$permits = $file->permits; // Getting Permits List2$permitted = $file->isPermitted($user); // Checking if permitted3 4$file->permit($user, '2027-07-7'); // Permitting a user5$file->forbid($user); // Forbidding a user
This is how you can delete your file and it's thumbnail too if found.
1$file->delete();