PHP code example of craigh / laravel-file-uploader
1. Go to this page and download the library: Download craigh/laravel-file-uploader 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/ */
protected $uploadDir; // Upload directory
protected $allowedMimeTypes = []; // Only allow these file to be uploaded
protected $blockedMimeTypes = []; // Don't allow these files to be uploaded
protected $maxFileSize = 1000000; // In bytes
protected $makeFilenameUnique = false; // Make the filename unique if two files have the same name
protected $overwrite = false; // Allow overwriting of files with the same name
protected $createDirs = false; // Allow the automatic creation of any upload directories
/**
* Example using dependency injection
**/
private $upload;
function __construct(ImageUploader $upload){
$this->upload = $upload;
}
public function store(Request $request){
$this->upload->file($request->file('file'))->move();
}
use Humps\LaravelFileUploader\LaravelFileUploaderExceptionHandler as BaseHandler;
class CustomUploadExceptionHandler extends BaseHandler {
protected function response(){
die($this->error);
}
}
use Humps\FileUploader\Uploader;
private $upload;
function __construct(Uploader $upload){
$this->upload = $upload;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.