AjaxUpload
Created by Thomas Jakobi on Sep 20, 2013.
What is AjaxUpload?
With this snippet an upload button for uploading multiple files with progress-bar is generated. Works well in FF3.6+, Safari4+, Chrome and falls back to hidden iframe based upload in other browsers, providing good user experience everywhere.
All uploaded images and generated thumbnails are given random filenames to avoid hotlinking uploaded not published fullsize images. Automatic thumbnail generation for uploaded jpeg, png and gif files. Other uploaded files will get a generic icon.
With two Formit hooks the upload queue could be pre filled from Formit field value and saved into Formit field value.
Requirements
- MODx Revolution 2.2.x or later
- PHP5.2 or later
Download
It can be downloaded from within the MODx Revolution manager via Package Management, or from the MODx Extras Repository, here: http://modx.com/extras/package/ajaxupload2
Support and Bug Reporting
Forum Thread: http://forums.modx.com/thread/86791/support-comments-for-ajaxupload
Bugtracker: https://github.com/Jako/AjaxUpload
Usage
Insert in Formit form
[[!AjaxUpload? &uid=`image` &allowedExtensions=`jpg,jpeg,png,gif` &thumbX=`75` &thumbY=`75` ]]
and use the Formit hooks
[[!Formit? ... &preHooks=`Formit2AjaxUpload` &hooks=`AjaxUpload2Formit` &ajaxuploadFieldname=`image` &ajaxuploadTarget=`images/user/` &ajaxuploadUid=`image` ]]
Snippet parameter
Property | Description | Default |
---|---|---|
uid | Unique upload queue id | md5 of MODX 'site_url' setting |
language | Snippet/Javascript language | - |
allowedExtensions | Allowed file extensions for upload | jpg,jpeg,png,gif |
maxFilesizeMb | Maximum size for one file to upload | 8 |
maxFiles | Maximum count of files to upload | 3 |
thumbX | Horizontal size of generated thumb | 100 |
thumbY | Vertical size of generated thumb | 100 |
addJquery | Add jQuery script at the end of the body | No |
addJscript | Add the snippet javascript and the fileuploader script at the end of the body | Yes |
addCss | Add the snippet css ad the end of the head | Yes |
Formit Hook Parameter
Property | Description | Default |
---|---|---|
ajaxuploadUid | Unique upload queue id | md5 of MODX 'site_url' setting |
ajaxuploadFieldname | (required) Formit field, the filenames/paths of the (already) uploaded files are saved in | - |
ajaxuploadTarget | (required) Target path for the (already) uploaded files (relative to $modx->getOption('assetsPath')) | - |
ajaxuploadFieldformat | Format of the data saved in ajaxuploadFieldname | csv |
Suggest an edit to this page on GitHub (Requires GitHub account. Opens a new window/tab).