Use for bootstap and Laravel project to upload file
Use Laravel storage to store upload files
This project require PHP imagick extension to save thumb and fit jpg file, (*1)
composer require virtualorz/fileupload
edit config/app.php, (*2)
'providers' => [ ... Virtualorz\Fileupload\FileuploadServiceProvider::class ] 'aliases' => [ ... 'Fileupload' => Virtualorz\Fileupload\Facades\Fileupload::class, ]
php artisan vendor:publish --provider="Virtualorz\Fileupload\FileuploadServiceProvider"
edit .env file add UPLOADDIR for dir name to save files under public dir
edit .env file add FILESYSTEM_DRIVER=public, (*3)
edit the 'disks' area, replace the 'public' to, (*4)
'public' => [ 'driver' => 'local', 'root' => public_path('uploads'), 'url' => env('APP_URL').'uploads', 'visibility' => 'public', ],
In view: And need an file element like : <input type="file" name="file" id="file" class="file_input" accept=".jpeg" multiple data-size="240*240" data-is_image="true"> accept attribute can edit to the file type you want multiple attribute can let you upload multiple files data-size is to check image size data-is_image set upload is image or not And after file element call {!! Fileupload::createUploadArea('UPLOAD_COLUMN_NAME',$files)!!} UPLOAD_COLUMN_NAME can edit to the column name you need In controller use $request->get('upload_file') to get upload files array
return bload html for view to generate file upload html area, in edit mode you can put the uploed file to $files variable
, (*5)
return bload html for view to generate file upload Result html area, use in detail page you can put the uploed file to $files variable
, (*6)