Dead simple Laravel file uploader.
Via Composer:
$ composer require nabilanam/simpleupload
You can publish the config file:
php artisan vendor:publish --provider="NabilAnam\SimpleUpload\SimpleUploadServiceProvider"
// somewhere in your controller
use NabilAnam\SimpleUpload\SimpleUpload;
public function update(Request $request, YourModel $model)
{
$model->image = (new SimpleUpload)
->file($request->image) // store normal request file
->fileBase64($request->image) // store file from base64 image data uri
->dirName('images') // directory to store the file into
->resizeImage(600, 100) // resize with intervention
->keepAspectRatio() // best fit aspect ratio by intervention
->intervention(function ($image) { // need more?
return $image;
})
->skipDay() // removes day directory from path
->skipMonth() // removes month directory from path
->skipYear() // removes year directory from path
->skipDirectory() // removes day, month, year directory from path
->deleteIfExists($model->image) // deletes file with given path
->save(); // processs && return final file path
$model->save();
return back();
}
// somewhere in your blade file
<img src="{{ asset($model->image) }}" alt="image">
Please see the changelog for more information on what has changed recently.
Pull requests are welcome!
If you discover any security related issues, please email nabil_code@outlook.com instead of using the issue tracker.
MIT. Please see the license file for more information.