Wiki source code of HTML5 File Upload Widget
Version 3.1 by Marius Dumitru Florea on 2014/11/13
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
1.1 | 1 | {{box cssClass="floatinginfobox" title="**Contents**"}} |
![]() |
2.3 | 2 | {{toc/}} |
![]() |
1.1 | 3 | {{/box}} |
4 | |||
![]() |
2.3 | 5 | {{info}} |
6 | This is a Javascript widget bundled by default with the XWiki platform since version 4.2-milestone-3 ([[XWIKI-8132>>http://jira.xwiki.org/browse/XWIKI-8132]]). | ||
7 | {{/info}} | ||
![]() |
1.1 | 8 | |
![]() |
2.3 | 9 | = Usage = |
![]() |
1.1 | 10 | |
11 | 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. | ||
12 | |||
13 | 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. | ||
14 | |||
15 | {{code language="javascript"}} | ||
16 | var targetInput = $('input-ID'); | ||
17 | if(targetInput) { | ||
18 | new XWiki.FileUploader(targetInput, { | ||
19 | autoUpload: true, | ||
20 | progressAutohide: true | ||
21 | }); | ||
22 | } | ||
23 | {{/code}} | ||
24 | |||
25 | [[image:html5uploads.png||class="screenshot"]] | ||
26 | |||
![]() |
2.3 | 27 | == Configuration options == |
![]() |
1.1 | 28 | |
29 | |=Option|=Details | ||
![]() |
3.1 | 30 | |autoUpload|Should the upload start as soon as the files are selected, or wait for a submit event? Defaults to ##true##. |
![]() |
1.1 | 31 | |enableFileInfo|Should information (name, type, size) about each selected file be displayed? Defaults to ##true##. |
32 | |enableProgressInfo|Should a progress bar be displayed as each file is uploaded? Defaults to ##true##. | ||
![]() |
3.1 | 33 | |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. |
34 | |maxFilesize|Maximum accepted file size, as a number. By default the maximum attachment size configured in the wiki is used. | ||
![]() |
1.1 | 35 | |progressAutohide|Should the progress information disappear automatically once all the uploads are completed? Defaults to ##false##. |
36 | |responseContainer|Where should the server response be displayed? If no container is provided, a new ##div## below the input will be created. | ||
37 | |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. | ||
![]() |
3.1 | 38 | |targetURL|Where to send the files? If no URL is given, then the file is sent to the normal target of the form. |