Download[RaggiTech] Laravel >= 6.0 - Uploader.
Laravel Uploader provides a quick and easy methods to upload files and handling visibility with simple routing.
Install
Install the latest version using Composer:
$ composer require raggitech/laravel-uploader
then publish the migration & config files $ php artisan vendor:publish --tag=laravel-uploader
$ php artisan migrate
Usage
<a name="config"></a>
Configurations / Options
/
* prefix => Hash Prefix
* visitable => Visits Counter
* private => Only Permitted Users
*/
<a name="UG"></a>
Uploading & Getting
function upload(UploadedFile $file, array $options = [])
function getUpload(string $hash)
// Upload File
$file = upload($request->image, [
'visitable' => true
]);
// Getting Uploaded File with Hash code
$file = getUploaded('5e63885fa771d1.12185481920ncF3...');
// Information
echo $file->hash; // File's Hash
echo $file->name; // File's Name
echo $file->path; // File's Path
echo $file->size; // File's Size in Bytes
echo $file->readableSize(); // File's Readable Size
echo $file->extension; // File's Extension
echo $file->mime; // File's MIME
echo $file->visits; // File's visits (Visitable File)
<a name="URL_UP"></a>
URL & Uploader
echo $file->url(); // Getting Uploaded File's URL
// <img src"{{ $file->url() }}" alt="{{ $file->name }}">
$user = $file->uploader; // Getting Uploader's Model
<a name="dd"></a>
Deleting Uploaded File
$file->delete();
<a name="permits"></a>
Permits (Private File)
$permits = $file->permits; // Getting Permits List
$permitted = $file->isPermitted($user); // Checking if permitted (App\User)
$file->permit($user, '2021-02-01'); // Permitting a user
$file->forbid($user); // Forbidding a user
License
MIT license |