A set of form file upload examples in a Zend Framework 2 module.
NOTE: Currently only compatible with the develop ZF2 branch, and requires the following patches: Multi-File Input Filtering, Session Progress fixes.
- Using a single File element.
- Using multiple File elements in a Collection.
- Using a single File element with the HTML5 "multiple" attribute.
- Temporarily save uploaded file(s) until a form is completely valid.
- Using file uploads with the Post-Redirect-Get plugin.
- Using AJAX to upload files and displaying progress with PHP5's Session Upload Progress.
See the Example Controllers for more details.
If there is a use-case for File uploads that you'd like to see and isn't currently included here, please create a GitHub issue.
- Install the ZendSkeletonApplication
- Clone this project into your
./vendor/
directory and enableZF2FileUploadExamples
in yourapplication.config.php
file. - Create a
./data/tmpuploads
directory, and make writeable by the webserver. - Download the jQuery Form plugin into
./public/js/jquery.form.js
(for the Upload Progress example). - Navigate to
/file-upload-examples
in your browser to see the list of examples.
You may also need to change/verify these php.ini
settings:
file_uploads = On
post_max_size = 50M
upload_max_filesize = 50M
session.upload_progress.enabled = On
session.upload_progress.freq = "1%"
session.upload_progress.min_freq = "1"
; Also make certain 'upload_tmp_dir' is writeable