Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 287 lines (178 sloc) 15.334 kb
fcc4fff8 »
2011-11-20 monster commit from moinconverter, which is always done prior to the …
1 .. _dojox/form/Uploader:
d608cc59 »
2011-11-20 \r\n -> \n conversion.
2
f89feb82 »
2011-11-28 regex change of level 1 headers to ====\nTEXT\n==== and level 2 heade…
3 =======================
9dd52dc6 »
2011-11-20 mondo whitespace change
4 dojox.form.Uploader
5 =======================
d608cc59 »
2011-11-20 \r\n -> \n conversion.
6
9dd52dc6 »
2011-11-20 mondo whitespace change
7 :Project owner: Mike Wilcox
8 :Author: Mike Wilcox
8e258548 »
2011-12-13 :Available: --> :since:
9 :since: 1.6
d608cc59 »
2011-11-20 \r\n -> \n conversion.
10
c15cbf24 »
2011-12-20 standardize spacing on directives like .. js
11 .. contents ::
9dd52dc6 »
2011-11-20 mondo whitespace change
12 :depth: 3
d608cc59 »
2011-11-20 \r\n -> \n conversion.
13
9dd52dc6 »
2011-11-20 mondo whitespace change
14 A widget that adds functionality to a standard HTML file input which allows file uploading to a server. The widget hides the actual uploader and substitutes a dijit.form.Button, so that the file input matches the rest of the user interface. If the browser supports the HTML5 file input specification, that functionality is used. If it is not supported (IE or older browsers) plugins are available to enhance the Uploader.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
15
9dd52dc6 »
2011-11-20 mondo whitespace change
16 **The dojox.form.Uploader is an improvement upon, and replaces the dojox.form.FileUploader**. The multiple problems created by Flash are avoided because it is not used in Mozilla and Webkit browsers. Support for FileUploader will cease as of 1.6, but the code will remain until 2.0 for backwards compatibility.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
17
9dd52dc6 »
2011-11-20 mondo whitespace change
18 Features
19 ========
d608cc59 »
2011-11-20 \r\n -> \n conversion.
20
9dd52dc6 »
2011-11-20 mondo whitespace change
21 - The Uploader is a Dijit, and supports all the same functionality as any other form widget. FileUploader made this claim, but it still had trouble due to its late build process and dependency on the Flash plugin.
22 - The Uploader may be placed in a form and will "just work". Actually, the Uploader will block the form's submit event and take over its duties of collecting the field values and uploading the data to the server using the form's action attribute, or the url property given to the Uploader.
23 - The tabIndex attribute is supported.
24 - An additional widget, dojox.form.uploader.FileList is provided to show the selection set and visualize the upload progress.
25 - :ref:`dojox.form.uploader.FileList <dojox/form/uploader/FileList>`
da94b0e8 »
2011-12-21 tabs --> spaces
26
a18758e4 »
2012-02-17 Adding AMD notes
27 Important AMD Note
28 ------------------
eb01c1d3 »
2012-02-17 Adding AMD notes
29
a18758e4 »
2012-02-17 Adding AMD notes
30 When using the Uploader programmatically, you cannot use the reference argument from require() - you must use the global. This is because the plugins redefine the original Uploader class, and AMD does not allow time for this to happen. In other this will NOT work:
eb01c1d3 »
2012-02-17 Adding AMD notes
31
32 .. js ::
33
a18758e4 »
2012-02-17 Adding AMD notes
34 require(['dojox/form/Uploader', 'dojox/form/uploader/plugins/Flash'], function(Uploader){
35 myUploader = Uploader(...);
36 });
eb01c1d3 »
2012-02-17 Adding AMD notes
37
38 Until 2.0, you must use:
39
40 .. js ::
41
a18758e4 »
2012-02-17 Adding AMD notes
42 require(['dojox/form/Uploader', 'dojox/form/uploader/plugins/Flash'], function(Uploader){
43 myUploader = new dojox.form.Uploader(...); // disregard reference argument
44 });
eb01c1d3 »
2012-02-17 Adding AMD notes
45
a18758e4 »
2012-02-17 Adding AMD notes
46 Important Form Note
47 -------------------
d608cc59 »
2011-11-20 \r\n -> \n conversion.
48
9dd52dc6 »
2011-11-20 mondo whitespace change
49 Because the Uploader uses your existing form, you must set its *enctype* to "multipart/form-data" which is used for uploading files.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
50
9dd52dc6 »
2011-11-20 mondo whitespace change
51 Missing Features
52 ----------------
d608cc59 »
2011-11-20 \r\n -> \n conversion.
53
9dd52dc6 »
2011-11-20 mondo whitespace change
54 The Uploader mimics the functionality of HTML5 file inputs, so some features available in the FileUploader are not (yet) available in Uploader. Specifically missing is the ability to add remove files from a current selection set. There are plans to implement this functionality soon.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
55
9dd52dc6 »
2011-11-20 mondo whitespace change
56 File mask (restricting the selection to certain file types) is in the HTML5 spec but missing from browser functionality. It is not supported.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
57
9dd52dc6 »
2011-11-20 mondo whitespace change
58 Usage
59 =====
d608cc59 »
2011-11-20 \r\n -> \n conversion.
60
9dd52dc6 »
2011-11-20 mondo whitespace change
61 The Uploader can be used in several variations.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
62
9dd52dc6 »
2011-11-20 mondo whitespace change
63 Uploader without Plugins
64 ------------------------
d608cc59 »
2011-11-20 \r\n -> \n conversion.
65
9dd52dc6 »
2011-11-20 mondo whitespace change
66 The Uploader with no plugins is in "Form" mode. This mode will not do an Ajax upload. It is expected that you plan to handle the upload yourself, whether via Ajax or changing the entire page via a POST. Only form POSTs will work and they will navigate to the UploadFile.php page in the test files. Multiple file selection is used in browsers that support it, and in the others, multiple selections are added one at a time by adding file inputs.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
67
9dd52dc6 »
2011-11-20 mondo whitespace change
68 Uploader with the HTML5 Plugin
69 ------------------------------
d608cc59 »
2011-11-20 \r\n -> \n conversion.
70
9dd52dc6 »
2011-11-20 mondo whitespace change
71 The HTML5 Uploader plugin does not support IE, it is more of a base class for IFrame or Flash, or used in cases where IE is not a requirement. For HTML5-capable browsers, this plugin provides an Ajax upload.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
72
9dd52dc6 »
2011-11-20 mondo whitespace change
73 Uploader with the IFrame Plugin
74 -------------------------------
d608cc59 »
2011-11-20 \r\n -> \n conversion.
75
9dd52dc6 »
2011-11-20 mondo whitespace change
76 The IFrame plugin will use the IFrame to upload in IE. All other browsers will use the HTML5 plugin unless *force="iframe"* is used.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
77
9dd52dc6 »
2011-11-20 mondo whitespace change
78 Uploader with the Flash Plugin
79 ------------------------------
d608cc59 »
2011-11-20 \r\n -> \n conversion.
80
9dd52dc6 »
2011-11-20 mondo whitespace change
81 The Flash plugin will use a SWF to upload in non-HTML5 browsers. All other browsers will use the HTML5 plugin, unless *force="flash"* is used, then Flash will be used in all browsers. *force="flash"* is provided because Flash has some features that HTML5 does not yet have. But it is still not recommended because of the many problems that Mozilla and Webkit have with the Flash plugin:
d608cc59 »
2011-11-20 \r\n -> \n conversion.
82
9dd52dc6 »
2011-11-20 mondo whitespace change
83 - Changing the display style on the DOM element that holds a SWF will reset the SWF. This makes it difficult to support Flash in Dijit Tabs and Dialog boxes.
84 - Initialization of a SWF is not always consistent and occasionally throws errors.
85 - HTTPS support in Mozilla is problematic.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
86
9dd52dc6 »
2011-11-20 mondo whitespace change
87 These problems do not occur in IE.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
88
9dd52dc6 »
2011-11-20 mondo whitespace change
89 Setup
90 =====
d608cc59 »
2011-11-20 \r\n -> \n conversion.
91
9dd52dc6 »
2011-11-20 mondo whitespace change
92 Markup
93 ------
d608cc59 »
2011-11-20 \r\n -> \n conversion.
94
9dd52dc6 »
2011-11-20 mondo whitespace change
95 To use the Uploader, simply require it and use the appropriate data-dojo-type in an input within a form:
d608cc59 »
2011-11-20 \r\n -> \n conversion.
96
c49c87d5 »
2011-11-21 normalization
97 .. js ::
ffa767cf »
2011-11-21 removing :linenos: rather than reverting previous commit. revert both…
98
9dd52dc6 »
2011-11-20 mondo whitespace change
99 dojo.require("dojox.form.Uploader");
d608cc59 »
2011-11-20 \r\n -> \n conversion.
100
c49c87d5 »
2011-11-21 normalization
101 .. html ::
ffa767cf »
2011-11-21 removing :linenos: rather than reverting previous commit. revert both…
102
9dd52dc6 »
2011-11-20 mondo whitespace change
103 <form method="post" action="UploadFile.php" id="myForm" enctype="multipart/form-data" >
459b3a14 »
2011-11-30 dojoType --> data-dojo-type
104 <input name="uploadedfile" multiple="true" type="file" data-dojo-type="dojox.form.Uploader" label="Select Some Files" id="uploader" />
105 <input type="submit" label="Submit" data-dojo-type="dijit.form.Button" />
9dd52dc6 »
2011-11-20 mondo whitespace change
106 </form>
d608cc59 »
2011-11-20 \r\n -> \n conversion.
107
108
9dd52dc6 »
2011-11-20 mondo whitespace change
109 Plugins will self initialize, so to use one, all that is needed is to require it. The following example uses the IFrame plugin, which inherits from the HTML5 plugin. So HTML5 file inputs are used when available and the IFrame technique used elsewhere (the HTML is exactly the same as the previous example):
d608cc59 »
2011-11-20 \r\n -> \n conversion.
110
c49c87d5 »
2011-11-21 normalization
111 .. js ::
ffa767cf »
2011-11-21 removing :linenos: rather than reverting previous commit. revert both…
112
9dd52dc6 »
2011-11-20 mondo whitespace change
113 dojo.require("dojox.form.Uploader");
114 dojo.require("dojox.form.uploader.plugins.IFrame");
d608cc59 »
2011-11-20 \r\n -> \n conversion.
115
c49c87d5 »
2011-11-21 normalization
116 .. html ::
ffa767cf »
2011-11-21 removing :linenos: rather than reverting previous commit. revert both…
117
9dd52dc6 »
2011-11-20 mondo whitespace change
118 <form method="post" action="UploadFile.php" id="myForm" enctype="multipart/form-data" >
459b3a14 »
2011-11-30 dojoType --> data-dojo-type
119 <input name="uploadedfile" multiple="true" type="file" data-dojo-type="dojox.form.Uploader" label="Select Some Files" id="uploader" />
120 <input type="submit" label="Submit" data-dojo-type="dijit.form.Button" />
9dd52dc6 »
2011-11-20 mondo whitespace change
121 </form>
d608cc59 »
2011-11-20 \r\n -> \n conversion.
122
123
9dd52dc6 »
2011-11-20 mondo whitespace change
124 Programmatic
125 ------------
d608cc59 »
2011-11-20 \r\n -> \n conversion.
126
9dd52dc6 »
2011-11-20 mondo whitespace change
127 Programmatic creation is also supported as shown in the following example that includes the Flash plugin:
d608cc59 »
2011-11-20 \r\n -> \n conversion.
128
c49c87d5 »
2011-11-21 normalization
129 .. js ::
ffa767cf »
2011-11-21 removing :linenos: rather than reverting previous commit. revert both…
130
9dd52dc6 »
2011-11-20 mondo whitespace change
131 dojo.require("dojox.form.Uploader");
132 dojo.require("dojox.form.uploader.plugins.Flash");
d608cc59 »
2011-11-20 \r\n -> \n conversion.
133
9dd52dc6 »
2011-11-20 mondo whitespace change
134 var u = new dojox.form.Uploader({label:"Programmatic Uploader", multiple:true, uploadOnSelect:true, url:"UploadFile.php"});
135 dojo.byId("myDiv").appendChild(u.domNode);
d608cc59 »
2011-11-20 \r\n -> \n conversion.
136
137
9dd52dc6 »
2011-11-20 mondo whitespace change
138 The "name" Property
139 -------------------
d608cc59 »
2011-11-20 \r\n -> \n conversion.
140
9dd52dc6 »
2011-11-20 mondo whitespace change
141 A key property to the Uploader is "name", which is subsequently used as the name attribute on the file input that is created, or as the field name that Flash assigns to each file. The default name is "uploadedfile" which works with the provided *UploadFile.php*. The HTML5 spec specifies that attributes that are array-like should use square brackets at the end of the field name. If a HTMl5-capable browser is used, the Uploader appends these brackets. It also appends an "s" at the end to help the server script determine the file data. If the Flash plugin is in use, the Uploader appends "Flash" to the end of the name, or whatever the "flashFieldName" property is set to. If a standard file input is in use (in "Form" mode or IFrame), the name is left as-is.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
142
9dd52dc6 »
2011-11-20 mondo whitespace change
143 The variations of the *name* attribute is necessary so that the server page knows what is being sent and can handle it appropriately.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
144
9dd52dc6 »
2011-11-20 mondo whitespace change
145 Other Properties
146 ----------------
d608cc59 »
2011-11-20 \r\n -> \n conversion.
147
9dd52dc6 »
2011-11-20 mondo whitespace change
148 - **flashFieldName** Is the text appended to the *name* property. This is necessary so the server can tell what type of file data it is dealing with.
149 - **multiple** Whether multiple files can or cannot be selected.
150 - **url** If you don't supply an *action* in your form, supply an *url* to upload to.
151 - **label** The text used in the button.
40dc7a99 »
2011-11-23 dojox/ spelling
152 - **tabIndex** Defaults to "0". You change this to change the tab order on the page.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
153
9dd52dc6 »
2011-11-20 mondo whitespace change
154 The Flash plugin has other properties specific to that file.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
155
9dd52dc6 »
2011-11-20 mondo whitespace change
156 Methods
157 -------
d608cc59 »
2011-11-20 \r\n -> \n conversion.
158
9dd52dc6 »
2011-11-20 mondo whitespace change
159 Because the Uploader without plugins doesn't upload, there are only the following methods:
d608cc59 »
2011-11-20 \r\n -> \n conversion.
160
9dd52dc6 »
2011-11-20 mondo whitespace change
161 - **reset** Clears the list of selected files.
162 - **getFileList** Returns an array of objects representing the file data.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
163
9dd52dc6 »
2011-11-20 mondo whitespace change
164 When using a plugin, the following methods will be available:
d608cc59 »
2011-11-20 \r\n -> \n conversion.
165
9dd52dc6 »
2011-11-20 mondo whitespace change
166 - **upload** This method uploads the files and any data passed as an argument.
167 - **submit** This method uploads the files and if a form element is passed as an argument, it is converted into a JavaScript object.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
168
9dd52dc6 »
2011-11-20 mondo whitespace change
169 Server Side
170 ===========
d608cc59 »
2011-11-20 \r\n -> \n conversion.
171
9dd52dc6 »
2011-11-20 mondo whitespace change
172 The file data is uploaded to a temp folder on the server. It's a misconception that your server side language has something to do with this. Receiving an uploaded file is handled by your server, meaning Apache or IIS. Typically the file is placed in a temp folder and it is your job to move it from there to the upload destination. Whether HTML or Flash, the payload is done with a multipart transfer. After the upload is complete, the server script is called.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
173
9dd52dc6 »
2011-11-20 mondo whitespace change
174 During a Flash multi-file upload, the images are uploaded in parallel (unless deferredUploading=true), however, the server script only receives one file at a time. So if five files are uploaded, the server script will be called five times.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
175
9dd52dc6 »
2011-11-20 mondo whitespace change
176 During an HTML multi-file upload, the files are all uploaded at once, and after all five are completely uploaded to the temp folder, the server script is called just once. For traditional HTML (Form mode or IFrame plugin) each file will be referenced as numerically sequenced fields: uploadedfile0, uploadedfile1, uploadedfile2, etc. For HTML5 uploads, the server script looks for "uploadedfiles" (with an "s"). the Uploader also added square brackets to the name ("uploadedfiles[]") to match the spec. The result is the files are given to the server script as an actual array.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
177
9dd52dc6 »
2011-11-20 mondo whitespace change
178 With a multipart request the POST data is the contents for the first part and the uploaded files is an array (or an object) of each additional part. Refer to your particular server documentation for how to reference the files (PHP is used as an example in the next section).
d608cc59 »
2011-11-20 \r\n -> \n conversion.
179
9dd52dc6 »
2011-11-20 mondo whitespace change
180 The return data needs to be formatted very specifically, and there are different formats for Flash and HTML. See **Server Side Return Data** below.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
181
9dd52dc6 »
2011-11-20 mondo whitespace change
182 Server Side Code PHP
183 --------------------
d608cc59 »
2011-11-20 \r\n -> \n conversion.
184
9dd52dc6 »
2011-11-20 mondo whitespace change
185 Uploader comes with a working PHP file, *dojox/form/tests/UploadFile.php*, to use as a reference for how your server side code should work. UploadFile.php has two dependencies, *dojo/tests/resources/JSON.php*, which is used for converting the return data to a JSON string, and *dojox/form/tests/cLog.php* which is used to log message to a text file, placed relative to the PHP file.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
186
9dd52dc6 »
2011-11-20 mondo whitespace change
187 UploadFile.php is expecting one of four things:
d608cc59 »
2011-11-20 \r\n -> \n conversion.
188
9dd52dc6 »
2011-11-20 mondo whitespace change
189 1) A file or files from Flash (uploadedfilesFlash)
da94b0e8 »
2011-12-21 tabs --> spaces
190 2) A file from HTML (uploadedfiles0)
9dd52dc6 »
2011-11-20 mondo whitespace change
191 3) Multiple files from HTML (uploadedfiles0, uploadedfiles1, etc)
192 4) A file array from HTML5 (uploadedfiles[])
d608cc59 »
2011-11-20 \r\n -> \n conversion.
193
9dd52dc6 »
2011-11-20 mondo whitespace change
194 The PHP file is inspecting the header and looking for the parameters set in Uploader. Whatever you set these parameters to, they must match on the server.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
195
9dd52dc6 »
2011-11-20 mondo whitespace change
196 The field name for the HTML uploader works much the same way. The only difference is if you do multi-file upload with HTML, this essentially continues to add fileInputs to the form, and in doing so, appends numbers to the fileInput field names, starting with '0'. That's why one file fieldname will look like "myFieldName" but two files will look like [ "myFieldName0", "myFieldName1" ] to the server side code.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
197
9dd52dc6 »
2011-11-20 mondo whitespace change
198 Server Side Return Data
199 -----------------------
d608cc59 »
2011-11-20 \r\n -> \n conversion.
200
9dd52dc6 »
2011-11-20 mondo whitespace change
201 How the data is returned from the server is not difficult, but it is very important. If not done correctly, it can be the cause of reported errors that the "onComplete" is not firing in Uploader.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
202
9dd52dc6 »
2011-11-20 mondo whitespace change
203 **NOTE** The Flash uploader and the HTML uploader need differently formatted return data. You will need to inspect the post data to determine which type to return.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
204
9dd52dc6 »
2011-11-20 mondo whitespace change
205 If *uploadedfilesFlash* is found in the post data and Flash is being used on the client side, all that is needed for return data is a key-value string, and it can simply be returned, as at the end of a function. Flash will parse these key-value pairs into an object and pass it to javaScript. You may also want to insert *exit* or whatever necessary to cease execution of the remainder of the code. Example:
d608cc59 »
2011-11-20 \r\n -> \n conversion.
206
c49c87d5 »
2011-11-21 normalization
207 .. html ::
ffa767cf »
2011-11-21 removing :linenos: rather than reverting previous commit. revert both…
208
9dd52dc6 »
2011-11-20 mondo whitespace change
209 $data .='file='.$file.',name='.$name.',width='.$width.',height='.$height.',type='.$type;
210 echo($data);
211 exit;
d608cc59 »
2011-11-20 \r\n -> \n conversion.
212
40dc7a99 »
2011-11-23 dojox/ spelling
213 For non-PHP developers this translates to:
d608cc59 »
2011-11-20 \r\n -> \n conversion.
214
9dd52dc6 »
2011-11-20 mondo whitespace change
215 .. code-block :: text
ffa767cf »
2011-11-21 removing :linenos: rather than reverting previous commit. revert both…
216
9dd52dc6 »
2011-11-20 mondo whitespace change
217 $name = name of the file, such as "PIC01.jpg"
218 $file = name of the file and the path, such as "uploaded/PIC01.jpg"
219 $width, $height = the dimensions (if you are working with images)
220 $type = the extension of the file - JPG, GIF, PNG, etc.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
221
222
9dd52dc6 »
2011-11-20 mondo whitespace change
223 The return to Flash should look like:
d608cc59 »
2011-11-20 \r\n -> \n conversion.
224
9dd52dc6 »
2011-11-20 mondo whitespace change
225 .. code-block :: text
ffa767cf »
2011-11-21 removing :linenos: rather than reverting previous commit. revert both…
226
9dd52dc6 »
2011-11-20 mondo whitespace change
227 "file=uploaded/PIC01.jpg,name=PIC01.jpg,width=320,height=240,type=jpg"
d608cc59 »
2011-11-20 \r\n -> \n conversion.
228
229
9dd52dc6 »
2011-11-20 mondo whitespace change
230 This string should be returned, or printed, or echoed.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
231
9dd52dc6 »
2011-11-20 mondo whitespace change
232 You can add an error key if one file was in error; say if it was not of the correct type. This error code or message will be returned in the onComplete dataArray. It's important to note that as far as the Uploader is concerned, everything was a success. It's up to your custom code to test for this error.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
233
9dd52dc6 »
2011-11-20 mondo whitespace change
234 The return string with an error might look like:
d608cc59 »
2011-11-20 \r\n -> \n conversion.
235
9dd52dc6 »
2011-11-20 mondo whitespace change
236 .. code-block :: text
ffa767cf »
2011-11-21 removing :linenos: rather than reverting previous commit. revert both…
237
9dd52dc6 »
2011-11-20 mondo whitespace change
238 "file=uploaded/PIC01.jpg,name=PIC01.jpg,width=320,height=240,type=jpg,error=Not recognized file type"
d608cc59 »
2011-11-20 \r\n -> \n conversion.
239
40dc7a99 »
2011-11-23 dojox/ spelling
240 You can also send back arbitrary parameters from your server-side script using this comma-delimited format. For example, adding variables foo and abc:
d608cc59 »
2011-11-20 \r\n -> \n conversion.
241
9dd52dc6 »
2011-11-20 mondo whitespace change
242 .. code-block :: text
ffa767cf »
2011-11-21 removing :linenos: rather than reverting previous commit. revert both…
243
9dd52dc6 »
2011-11-20 mondo whitespace change
244 "file=uploaded/PIC01.jpg,name=PIC01.jpg,width=320,height=240,type=jpg,foo=bar,abc=123"
d608cc59 »
2011-11-20 \r\n -> \n conversion.
245
9dd52dc6 »
2011-11-20 mondo whitespace change
246 Then you can access these variables in the client-side functions using dataArray[i].additionalParams.foo and dataArray[i].additionalParams.abc.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
247
9dd52dc6 »
2011-11-20 mondo whitespace change
248 If IFrame plugin is used, the code on the client side gets tricky, as reading back from an iframe presents problems. In order to read the iframe return data accurately cross browser, the code needs to be wrapped in a *<textarea>*. You can see the code for this on the very last line of UploadFiles.php. Note that the textarea needs to be outside of the PHP. Example:
d608cc59 »
2011-11-20 \r\n -> \n conversion.
249
c49c87d5 »
2011-11-21 normalization
250 .. html ::
ffa767cf »
2011-11-21 removing :linenos: rather than reverting previous commit. revert both…
251
9dd52dc6 »
2011-11-20 mondo whitespace change
252 <?php
253 ....code....
254 ?>
255 <textarea><?php print $json->encode($dataObject); ?></textarea>
d608cc59 »
2011-11-20 \r\n -> \n conversion.
256
9dd52dc6 »
2011-11-20 mondo whitespace change
257 For non-PHP devs, this translates into a JSON string, wrapped in a textarea, returned as HTML. I know it's screwy, but that's how it works.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
258
9dd52dc6 »
2011-11-20 mondo whitespace change
259 If you are having problems getting *onComplete* to fire, look at this code first. Often the problem is the server side code is not catching the field name for whatever reason (perhaps the client and server names don't match) and the code is falling to the end of the page and returning a textarea when it shouldn't.
d608cc59 »
2011-11-20 \r\n -> \n conversion.
260
9dd52dc6 »
2011-11-20 mondo whitespace change
261 Examples
262 ========
d608cc59 »
2011-11-20 \r\n -> \n conversion.
263
9dd52dc6 »
2011-11-20 mondo whitespace change
264 This example shows how to use Flash and IFrame plugins for both cases (browsers with and without flash).
d608cc59 »
2011-11-20 \r\n -> \n conversion.
265
4413e3bd »
2011-12-21 yet more fixes removing unneeded <script> and <style> tags
266 .. js ::
ffa767cf »
2011-11-21 removing :linenos: rather than reverting previous commit. revert both…
267
9dd52dc6 »
2011-11-20 mondo whitespace change
268 dojo.require("dojox.form.Uploader");
269 dojo.require("dojox.embed.Flash");
67f7d9eb »
2011-12-01 Fix spacing for braces, function(), if(), while(), for(), else, etc. …
270 if(dojox.embed.Flash.available){
9dd52dc6 »
2011-11-20 mondo whitespace change
271 dojo.require("dojox.form.uploader.plugins.Flash");
67f7d9eb »
2011-12-01 Fix spacing for braces, function(), if(), while(), for(), else, etc. …
272 }else{
9dd52dc6 »
2011-11-20 mondo whitespace change
273 dojo.require("dojox.form.uploader.plugins.IFrame");
274 }
49acd5cd »
2011-11-24 change dojo.addOnLoad() --> dojo.ready(), except for:
275 dojo.ready(function(){
9dd52dc6 »
2011-11-20 mondo whitespace change
276 var u = new dojox.form.Uploader({
277 label: "Select files",
278 multiple: true,
279 uploadOnSelect: true,
280 url: "UploadFile.php",
281 }, "uploader");
f3367114 »
2012-04-02 Close statement
282 });
4413e3bd »
2011-12-21 yet more fixes removing unneeded <script> and <style> tags
283
284 .. html ::
d608cc59 »
2011-11-20 \r\n -> \n conversion.
285
9dd52dc6 »
2011-11-20 mondo whitespace change
286 <div id="uploader"></div>
Something went wrong with that request. Please try again.