When creating a new instance of Hazzard\Filepicker\Uploader you pass a Hazzard\Config\Repository that you use to set configuration options:
use Hazzard\Filepicker\Uploader;
use Intervention\Image\ImageManager;
use Hazzard\Config\Repository as Config;
$uploader = new Uploader($config = new Config, new ImageManager);
Set configuration options:
$config['debug'] = true;
// or
$config->set('upload_dir', __DIR__.'/../files');
The second argument is an instance of Intervention Image which supports two image processing extensions: GD and Imagick. The default driver is GD, to change it just pass the configuration as an array directly into the ImageManager instance:
$manager = new ImageManager(array('driver' => 'imagick'));
$uploader = new Uploader($config = new Config, $manager);
Notice: Make sure you have installed Imagick if you want to use it.
If enabled, more detailed error messages will be shown on every error that occurs, otherwise a simple generic error is shown.
falseThe directory where the files are uploaded. Make sure to use absolute paths and the directory has read/write permissions.
n/a__DIR__.'/../files'The url to the directory where the files are uploaded.
n/ahttp://localhost/filepicker/filesThe url to the file where the ajax requests are sent.
http://localhost/filepicker/uploader/index.phpThe minimum file size required (in Bytes).
11000 (= 1 Kilobyte)The maximum file size allowed (in Bytes).
n/a10000000 (= 10 Megabyes)The accepted file types.
n/ajpg|png|txt|pdf|mp3The accepted file types regular expresion.
n/aThe rejected file types.
php|phtml|php3|php5|phpsFiles that should be handled as images. Used for validation and creating image versions.
gif|jpg|jpeg|pngFile types that should be handled as inline files, used when php_download is enabled.
gif|jpg|jpeg|png|pdf|txt|js|cssThe maximum number of files allowed to be uploaded to the upload_dir
n/a20Whether to use direct file links or donwload the files via PHP.
falseThe min/max width/height for image type files.
1 / n\aAn array with image versions that are created for each uploaded image. The key of each element will be the version name and the value will be an array contain the version constraints. The default version will have an empty key.
array(
'' => array(
'auto_orient' => true,
),
'thumb' => array(
'crop' => true,
'max_width' => 100,
'max_height' => 100,
),
),
Auto orient the image based on EXIF data.
Create a square image instead of just scaling the image version.
The image version maximum width.
The image version maximum height.
The quality of the image (0 - 100).
90Custom directory where the image version is created. Make sure to use absolute paths and the directory has read/write permissions. If is the same as the global upload_dir directory then, the image version will be named like this:filename-version.jpg.
. '/version'__DIR__.'/../files'Custom url to the directory where the image version is created.
. '/version'http://localhost/filepicker/filesCallback fired before creating the image version. The callback has two arguments, $image which is an instance of \Intervention\Image\Image (see Intervention Image) and $version, the version name. Returning false will cancel the crop.
n/aExample:
/**
*
* @param \Intervention\Image\Image $image
* @param string $version
*/
'before' => function($image, $version) {
// return false;
},
Callback fired after creating the image version. Same as the before callback, except with no return.
n/aWhether to keep the original image without cropping it. This allows to use the original image for later re-crop.
falseThe alphabetical sorting order when scaning the directory for files with scandir.
Use 0 for ascending order, and 1 for descending order. In PHP 5.4 you can use SCANDIR_SORT_NONE for unsorted.
0The mode used when creating directories with mkdir.
0777An array with all error messages.
array(
'no_file' => 'No file was uploaded.',
'max_width' => 'Image exceeds maximum width of %d pixels.',
'min_width' => 'Image requires a minimum width of %d pixels.',
'max_height' => 'Image exceeds maximum height of %d pixels.',
'min_height' => 'Image requires a minimum height of %d pixels.',
'image_resize' => 'Failed to resize image versions (%s).',
'upload_failed' => 'Failed to upload the file (error %d).',
'max_file_size' => 'The file exceeds the maximum allowed file size (limit is %d KB).',
'min_file_size' => 'The file size is too small.',
'accept_file_types' => 'The file type is not allowed.',
'max_number_of_files' => 'Maximum number of files exceeded.',
'error' => 'Oops! Something went wrong.',
'abort' => 'The operation was aborted.',
'404' => 'File not found.',
'401' => 'Unauthorized.',
),