HTML5 File Upload Widget
Version 2.3 by Manuel Smeria on 2013/02/18
Contents
Usage
The File Upload widget can enhance HTML input elements of type file to provide an interactive upload UI. It can submit files either automatically when the user selects local files, or after the user presses the container form's submit button.
To use this widget, it is enough to create a new instance of XWiki.FileUploader passing the target input element as the first parameter, and an optional configuration object as the second parameter.
var targetInput = $('input-ID');
if(targetInput) {
new XWiki.FileUploader(targetInput, {
autoUpload: true,
progressAutohide: true
});
}
if(targetInput) {
new XWiki.FileUploader(targetInput, {
autoUpload: true,
progressAutohide: true
});
}
Configuration options
Option | Details |
---|---|
maxFilesize | Maximum accepted file size, as a number. By default the maximum attachment size configured in the wiki is used. |
fileFilter | Regular expression defining accepted MIME types, as a valid JavaScript RegExp object. For example, /image\/.*/ for accepting only images. By default all MIME types are allowed. |
enableFileInfo | Should information (name, type, size) about each selected file be displayed? Defaults to true. |
enableProgressInfo | Should a progress bar be displayed as each file is uploaded? Defaults to true. |
progressAutohide | Should the progress information disappear automatically once all the uploads are completed? Defaults to false. |
autoUpload | Should the upload start as soon as the files are selected, or wait for a submit event? Defaults to true. |
responseContainer | Where should the server response be displayed? If no container is provided, a new div below the input will be created. |
responseURL | A custom URL to be used for obtaining the response after the files are uploaded. If an URL isn't provided, an existing xredirect parameter in the form is going to be used. |