Download the PHP package gargron/fileupload without Composer
On this page you can find all versions of the php package gargron/fileupload. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gargron/fileupload
More information about gargron/fileupload
Files in gargron/fileupload
Package fileupload
Short Description File uploading library capable of handling large/chunked/multiple file uploads
License MIT
Informations about the package fileupload
FileUpload
PHP FileUpload library that supports chunked uploads. Adopted from the procedural script included with jQuery-File-Upload, designed to work with that JavaScript plugin, with normal forms, and to be embeddable into any application/architecture.
Installing
This package is available via Composer:
Requirements
-
Ensure that the PHP extension "php_fileinfo" is enabled;
- Your php.ini must have the next directive:
file_uploads = On
Status
The unit test suite covers simple uploads and the library "works on my machine", as it were. You are welcome to contribute.
You can grep the source code for TODO
to find things you could help finishing.
Usage
Alternative usage via factory
Validators
There are currently 4 validators shipped with FileUpload
:
-
Simple
-
MimeTypeValidator
-
SizeValidator
DimensionValidator
Remember to register new validator(s) by
$fileuploadInstance->addValidator($validator);
If you want you can use the common human readable format for filesizes like '1M', '1G', just pass the string as the first argument.
Here is a listing of the possible values (B => B; KB => K; MB => M; GB => G). These values are binary convention so basing on 1024.
FileNameGenerator
With the FileNameGenerator
you have the possibility to change the filename the uploaded files will be saved as.
-
Custom
-
MD5
-
Random
-
Simple
Slug
Remember to register new validator(s) by
$fileuploadInstance->setFileNameGenerator($generator);
Every call to
setFileNameGenerator
overrides the currently set$generator
Callbacks
Currently implemented events:
-
completed
-
beforeValidation
afterValidation
Extending
The reason why the path resolver, the validators and the file system are abstracted, is so you can write your own, fitting your own needs (and also, for unit testing). The library is shipped with a bunch of "simple" implementations which fit the basic needs. You could write a file system implementation that works with Amazon S3, for example.
License
Licensed under the MIT license, see LICENSE
file.