PHP code example of kapitanpulido / storagefile
1. Go to this page and download the library: Download kapitanpulido/storagefile 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/ */
kapitanpulido / storagefile example snippets
use kapitanpulido\StorageFile\StorageFile;
$model = Model::find($id);
if ($file = $request->file('element')){
if ($model->filename){
StorageFile::deleteFile('my_folder', $model->filename);
}
$unique_filename = StorageFile::generateUniqueFileName('my_folder', $file->getClientOriginalName());
StorageFile::saveFile($file, 'my_folder', $unique_filename);
}