Download the PHP package cohensive/upload without Composer
On this page you can find all versions of the php package cohensive/upload. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package upload
Upload
Handle file uploading via standard HTML multipart form or via XHR data stream.
Usage
Upload can be used alone as any class or as a package for Laravel 4 framework (if you'd like to add support to any other frameworks, write to the issues or make a pull request with required changes).
First, add following line to the list of requirements in composer.json:
`
Run composer install
or composer update
to download it and autoload.
Laravel 4/5
Get package config file - not required, but maybe handy if you have a lot of various upload fields and you want to change default Upload options.
``
In providers
array you need to add new package:
``
In aliases add Upload facade:
``
Using in the code
``
What to do with uploaded files next is out of the scope of Upload.
Standalone
As a standalone package you'll have to instantiate several classes that Upload depends on. Namely:
-
Validator - will validate files agains a set of rules.
-
Sanitizer - will keep filename safe for web (transliteration to ascii). It has one required parameter - instantiated class that will do the file sanitization. Various framework has own versions of such class often called Transliterator or Inflector. You just use its instance as a first argument and as a second parameter include method name that will be used for sanitization. Alternatively, you can create a wrapper for you Inflector which implements \Cohensive\Upload\Sanitizer\SanitizerInterface
- FileHandlerFactory - will create FileHandlers based on the method of uploading
``
Using in the code
``
Handling file post-save.
After file has been successfully validated and saved, Upload will return File
class instance which contains number of methods:
``
Options
Uploader accets an array of options on instantiation:
``
Rules
An array of rules that could be used while validation uploaded files:
``