1. Go to this page and download the library: Download nabilanam/simpleupload 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/ */
nabilanam / simpleupload example snippets
// 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">