|
525
|
1 |
<!DOCTYPE html> |
|
|
2 |
<html lang="en"> |
|
|
3 |
<head> |
|
|
4 |
<meta charset="utf-8"> |
|
|
5 |
<title>Uploader</title> |
|
|
6 |
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Sans:400,700,400italic,700italic"> |
|
|
7 |
<link rel="stylesheet" href="../../build/cssgrids/cssgrids-min.css"> |
|
|
8 |
<link rel="stylesheet" href="../assets/css/main.css"> |
|
|
9 |
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css"> |
|
|
10 |
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png"> |
|
|
11 |
<script src="../../build/yui/yui-min.js"></script> |
|
|
12 |
|
|
|
13 |
</head> |
|
|
14 |
<body> |
|
|
15 |
<!-- |
|
|
16 |
<a href="https://github.com/yui/yui3"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a> |
|
|
17 |
--> |
|
|
18 |
<div id="doc"> |
|
|
19 |
<div id="hd"> |
|
|
20 |
<h1><img src="http://yuilibrary.com/img/yui-logo.png"></h1> |
|
|
21 |
</div> |
|
|
22 |
|
|
|
23 |
<a href="#toc" class="jump">Jump to Table of Contents</a> |
|
|
24 |
|
|
|
25 |
|
|
|
26 |
<h1>Uploader</h1> |
|
|
27 |
<div class="yui3-g"> |
|
|
28 |
<div class="yui3-u-3-4"> |
|
|
29 |
<div id="main"> |
|
|
30 |
<div class="content"><style> |
|
|
31 |
#docs-main li { |
|
|
32 |
margin: 1ex 0; |
|
|
33 |
} |
|
|
34 |
|
|
|
35 |
li code, |
|
|
36 |
td code { |
|
|
37 |
white-space: nowrap; |
|
|
38 |
background: #fcfbfa; |
|
|
39 |
border: 1px solid #d0d5ec; |
|
|
40 |
padding: 0 3px; |
|
|
41 |
} |
|
|
42 |
li code { |
|
|
43 |
border-color: #efeeed; |
|
|
44 |
} |
|
|
45 |
.yui3-skin-sam table { |
|
|
46 |
width: auto; |
|
|
47 |
} |
|
|
48 |
.yui3-skin-sam td, |
|
|
49 |
.yui3-skin-sam th { |
|
|
50 |
border: 0 none; |
|
|
51 |
} |
|
|
52 |
|
|
|
53 |
.demo { width: 40%; } |
|
|
54 |
.details { width: 60%; } |
|
|
55 |
.before, .after { width: 47%; } |
|
|
56 |
.after { |
|
|
57 |
margin-left: 5%; |
|
|
58 |
} |
|
|
59 |
|
|
|
60 |
#quickref code em { |
|
|
61 |
color: #900; |
|
|
62 |
} |
|
|
63 |
#quickref code strong { |
|
|
64 |
color: #090; |
|
|
65 |
} |
|
|
66 |
#quickref pre.code { |
|
|
67 |
margin-top: 0; |
|
|
68 |
margin-bottom: 0; |
|
|
69 |
} |
|
|
70 |
|
|
|
71 |
.spendy { |
|
|
72 |
color: #b00; |
|
|
73 |
} |
|
|
74 |
</style> |
|
|
75 |
<div class="intro"> |
|
|
76 |
<p> |
|
|
77 |
Uploader has been rebuilt in version 3.5.0, and a number of additional |
|
|
78 |
supporting modules (<code>UploaderFlash</code>, <code>UploaderHTML5</code>, <code>Uploader.Queue</code> |
|
|
79 |
and <code>File</code>) have been added. The new architecture is <strong>not fully |
|
|
80 |
backward-compatible</strong> with versions 3.4.1 and prior. This guide |
|
|
81 |
is to help answer questions that may come up when upgrading to the latest |
|
|
82 |
version. |
|
|
83 |
</p> |
|
|
84 |
|
|
|
85 |
<p> |
|
|
86 |
This guide focuses on 3.4.1 API compatibility. It <strong>does not |
|
|
87 |
describe new features added in 3.5.0</strong>. |
|
|
88 |
Refer to the updated <a href="index.html">Uploader user guide</a> for |
|
|
89 |
that. |
|
|
90 |
</p> |
|
|
91 |
|
|
|
92 |
<p> |
|
|
93 |
If you are unable to upgrade due to unresolvable issues, you can use the |
|
|
94 |
<a href="../uploader-deprecated/index.html"><code>uploader-deprecated</code></a> |
|
|
95 |
module, which is equivalent to the 3.4.1 implementation. But be |
|
|
96 |
aware that this module will be removed in a future version of YUI. |
|
|
97 |
</p> |
|
|
98 |
</div> |
|
|
99 |
|
|
|
100 |
<h2 id="overview">Overview of API changes from 3.4.1</h2> |
|
|
101 |
|
|
|
102 |
<p> |
|
|
103 |
The architectural changes resulted in the deprecation, replacement, or |
|
|
104 |
removal of some of the attributes, properties, methods and events from |
|
|
105 |
3.4.1 version of the Uploader. Here is a quick list of the changes most |
|
|
106 |
likely to affect your upgrade: |
|
|
107 |
</p> |
|
|
108 |
|
|
|
109 |
<h3 id="attribute-changes">Attribute changes</h3> |
|
|
110 |
<table> |
|
|
111 |
<tr> |
|
|
112 |
<th>Attribute in 3.4.1</th> |
|
|
113 |
<th>Change in 3.5.0</th> |
|
|
114 |
</tr> |
|
|
115 |
<tr> |
|
|
116 |
<td><code>buttonSkin</code></td> |
|
|
117 |
<td><strong>No longer exists.</strong> The Uploader in Flash mode is now always rendered |
|
|
118 |
as transparent, overlaying a "Select Files" button that can be replaced |
|
|
119 |
with any control (with any skin) using the <code>selectFilesButton</code> attribute. |
|
|
120 |
</td> |
|
|
121 |
</tr> |
|
|
122 |
<tr> |
|
|
123 |
<td><code>fileFilters</code></td> |
|
|
124 |
<td>Only available when the Uploader is in <strong>Flash mode</strong>, and has no effect |
|
|
125 |
when the Uploader is in HTML5 mode. If filtering by extension is needed |
|
|
126 |
across all Uploader modes, it is best to implement it post-selection, |
|
|
127 |
by validating individual elements in the <code>fileList</code>. |
|
|
128 |
</td> |
|
|
129 |
</tr> |
|
|
130 |
<tr> |
|
|
131 |
<td><code>log</code></td> |
|
|
132 |
<td><strong>No longer exists.</strong> All necessary uploader information is transmitted via |
|
|
133 |
events. |
|
|
134 |
</td> |
|
|
135 |
</tr> |
|
|
136 |
<tr> |
|
|
137 |
<td><code>multiFiles</code></td> |
|
|
138 |
<td>Renamed to <code>multipleFiles</code></td> |
|
|
139 |
</tr> |
|
|
140 |
<tr> |
|
|
141 |
<td><code>transparent</code></td> |
|
|
142 |
<td><strong>No longer exists.</strong> The Uploader in Flash mode is now always rendered as |
|
|
143 |
a transparent overlay over a "Select Files" button that can be customized |
|
|
144 |
or replaced with any control using the <code>selectFilesButton</code> attribute.</td> |
|
|
145 |
</tr> |
|
|
146 |
</table> |
|
|
147 |
|
|
|
148 |
|
|
|
149 |
<h3 id="method-changes">Method changes</h3> |
|
|
150 |
<table> |
|
|
151 |
<tr> |
|
|
152 |
<th>Method in 3.4.1</th> |
|
|
153 |
<th>Change in 3.5.0</th> |
|
|
154 |
</tr> |
|
|
155 |
<tr> |
|
|
156 |
<td><code>cancel</code></td> |
|
|
157 |
<td><strong>No longer exists</strong> on the Uploader instance. Instead, a <code>cancelUpload()</code> method is present on the instance of Uploader's queue, stored in <code>uploaderInstance.queue</code>. |
|
|
158 |
(See the <a href="http://yuilibrary.com/yui/docs/api/classes/Uploader.Queue.html#method_cancelUpload">API Docs</a> for more information). |
|
|
159 |
</td> |
|
|
160 |
</tr> |
|
|
161 |
<tr> |
|
|
162 |
<td><code>clearFileList</code></td> |
|
|
163 |
<td><strong>No longer exists</strong>. Instead, you can directly manipulate the <code>fileList</code> |
|
|
164 |
attribute.</td> |
|
|
165 |
</tr> |
|
|
166 |
<tr> |
|
|
167 |
<td><code>enable</code></td> |
|
|
168 |
<td><strong>No longer exists</strong>. Instead, set the <code>enabled</code> attribute to either <code>true</code> or <code>false</code>.</td> |
|
|
169 |
</tr> |
|
|
170 |
<tr> |
|
|
171 |
<td><code>disable</code></td> |
|
|
172 |
<td><strong>No longer exists</strong>. Instead, set the <code>enabled</code> attribute to either <code>true</code> or <code>false</code>.</td> |
|
|
173 |
</tr> |
|
|
174 |
<tr> |
|
|
175 |
<td><code>removeFile</code></td> |
|
|
176 |
<td><strong>No longer exists</strong>. Instead, you can directly manipulate the <code>fileList</code> |
|
|
177 |
attribute.</td> |
|
|
178 |
</tr> |
|
|
179 |
<tr> |
|
|
180 |
<td><code>upload</code></td> |
|
|
181 |
<td><strong>The method signature has changed</strong>. The new <code>upload()</code> method takes |
|
|
182 |
<code>file</code>, <code>url</code>, and <code>postVars</code> as arguments, where <code>file</code> is a references to an instance |
|
|
183 |
of <code>Y.File</code> (can be obtained from the <code>fileList</code> attribute), <code>url</code> is the target URL |
|
|
184 |
to upload the file to, and <code>postVars</code> is a set of key-value pairs specifying the variables |
|
|
185 |
that should be POSTed along with the file upload. The old <code>method</code> argument has been removed since file upload requests are always POSTed. The old <code>postFileVarName</code> argument has been replaced with an instance-level <code>fileFieldName</code> attribute. (See the <a href="http://yuilibrary.com/yui/docs/api/classes/UploaderFlash.html#method_upload">API Docs</a> for more information).</td> |
|
|
186 |
</tr> |
|
|
187 |
<tr> |
|
|
188 |
<td><code>uploadAll</code></td> |
|
|
189 |
<td><strong>The method signature has changed</strong>. The new <code>uploadAll()</code> method takes |
|
|
190 |
<code>url</code>, and <code>postVars</code> as arguments, where <code>url</code> is the target URL to upload the files to, and <code>postVars</code> is a set of key-value pairs specifying the variables that should be POSTed along with the file upload. If POST variables need to be specified per file, you can use the <code>postVarsPerFile</code> attribute instead of specifying the third argument. The old <code>method</code> argument has been removed since file upload requests are always POSTed. The old <code>postFileVarName</code> argument has been replaced with an instance-level <code>fileFieldName</code> attribute. (See the <a href="http://yuilibrary.com/yui/docs/api/classes/UploaderFlash.html#method_uploadAll">API Docs</a> for more information).</td> |
|
|
191 |
</tr> |
|
|
192 |
<tr> |
|
|
193 |
<td><code>uploadThese</code></td> |
|
|
194 |
<td><strong>The method signature has changed</strong>. The new <code>uploadThese()</code> method takes |
|
|
195 |
<code>files</code>, <code>url</code>, and <code>postVars</code> as arguments, where <code>files</code> is an array of <code>Y.File</code> instances (can be obtained as a subset of <code>fileList</code> attribute), <code>url</code> is the target URL to upload the files to, and <code>postVars</code> is a set of key-value pairs specifying the variables that should be POSTed along with the file upload. If POST variables need to be specified per file, you can use the <code>postVarsPerFile</code> attribute instead of specifying the third argument. The old <code>method</code> argument has been removed since file upload requests are always POSTed. The old <code>postFileVarName</code> argument has been replaced with an instance-level <code>fileFieldName</code> attribute. (See the <a href="http://yuilibrary.com/yui/docs/api/classes/UploaderFlash.html#method_uploadThese">API Docs</a> for more information).</td> |
|
|
196 |
</tr> |
|
|
197 |
</table> |
|
|
198 |
<h2 id="progressive-enhancement">Improved Progressive Enhancement</h2> |
|
|
199 |
|
|
|
200 |
The progressive enhancement scenario has been improved in 3.5.0 Uploader. The Uploader now keeps a static <code>TYPE</code> property (<code>Y.Uploader.TYPE</code>), which you can check before creating an instance of Uploader or modifying its configuration settings. We recommend the following pattern for using Uploader on your pages: |
|
|
201 |
|
|
|
202 |
<pre class="code prettyprint">if (Y.Uploader.TYPE != "none") { |
|
|
203 |
|
|
|
204 |
var uploaderInstance = new Y.Uploader(....); // Common configuration settings. |
|
|
205 |
|
|
|
206 |
if (Y.Uploader.TYPE == "html5") { |
|
|
207 |
// Additional configuration settings for an HTML5 uploader, |
|
|
208 |
// e.g. a drag-and-drop area specification, etc. |
|
|
209 |
} |
|
|
210 |
|
|
|
211 |
else if (Y.Uploader.TYPE == "flash") { |
|
|
212 |
// Flash-specific configuration settings, |
|
|
213 |
// e.g. a fileFilters setting, etc. |
|
|
214 |
} |
|
|
215 |
|
|
|
216 |
// Render the uploader |
|
|
217 |
uploaderInstance.render("#selectFilesButtonContainer"); |
|
|
218 |
} |
|
|
219 |
|
|
|
220 |
else { |
|
|
221 |
|
|
|
222 |
// Don't render the uploader and use predefined basic functionality |
|
|
223 |
// instead (e.g. a simple upload form field). |
|
|
224 |
|
|
|
225 |
}</pre> |
|
|
226 |
|
|
|
227 |
|
|
|
228 |
<h2 id="backend-setup">Backend Setup</h2> |
|
|
229 |
|
|
|
230 |
The backend requirements for the Flash version of the Uploader have not changed. However, the XMLHttpRequest Level 2 cross-domain request security model is different from that in Flash, and needs a different type of verification from the backend that receives POST requests with uploaded files. See the <a href="index.html#backend-setup">Backend Setup</a> section in the User Guide for more information, or read more about it on the <a href="http://www.html5rocks.com/en/tutorials/cors/#toc-handling-a-not-so-simple-request">HTML5Rocks website.</a> |
|
|
231 |
|
|
|
232 |
<h2 id="help-me">What Did We Miss?</h2> |
|
|
233 |
|
|
|
234 |
<p> |
|
|
235 |
Obviously, there were quite a few changes to Uploader from 3.4.1 to 3.5.0. |
|
|
236 |
It's likely that we missed something here. If you experience trouble with |
|
|
237 |
your upgrade and find this migration guide is missing something important, |
|
|
238 |
please <a href="/projects/yui3/newticket">file a ticket</a> and we'll update |
|
|
239 |
it as soon as possible. |
|
|
240 |
</p> |
|
|
241 |
|
|
|
242 |
<p> |
|
|
243 |
Additional resources to help with the upgrade include the <a href="/forum">forums</a>, |
|
|
244 |
and the #yui IRC channel on freenode.net. |
|
|
245 |
</p> |
|
|
246 |
</div> |
|
|
247 |
</div> |
|
|
248 |
</div> |
|
|
249 |
|
|
|
250 |
<div class="yui3-u-1-4"> |
|
|
251 |
<div class="sidebar"> |
|
|
252 |
|
|
|
253 |
<div id="toc" class="sidebox"> |
|
|
254 |
<div class="hd"> |
|
|
255 |
<h2 class="no-toc">Table of Contents</h2> |
|
|
256 |
</div> |
|
|
257 |
|
|
|
258 |
<div class="bd"> |
|
|
259 |
<ul class="toc"> |
|
|
260 |
<li> |
|
|
261 |
<a href="#overview">Overview of API changes from 3.4.1</a> |
|
|
262 |
<ul class="toc"> |
|
|
263 |
<li> |
|
|
264 |
<a href="#attribute-changes">Attribute changes</a> |
|
|
265 |
</li> |
|
|
266 |
<li> |
|
|
267 |
<a href="#method-changes">Method changes</a> |
|
|
268 |
</li> |
|
|
269 |
</ul> |
|
|
270 |
</li> |
|
|
271 |
<li> |
|
|
272 |
<a href="#progressive-enhancement">Improved Progressive Enhancement</a> |
|
|
273 |
</li> |
|
|
274 |
<li> |
|
|
275 |
<a href="#backend-setup">Backend Setup</a> |
|
|
276 |
</li> |
|
|
277 |
<li> |
|
|
278 |
<a href="#help-me">What Did We Miss?</a> |
|
|
279 |
</li> |
|
|
280 |
</ul> |
|
|
281 |
</div> |
|
|
282 |
</div> |
|
|
283 |
|
|
|
284 |
|
|
|
285 |
|
|
|
286 |
<div class="sidebox"> |
|
|
287 |
<div class="hd"> |
|
|
288 |
<h2 class="no-toc">Examples</h2> |
|
|
289 |
</div> |
|
|
290 |
|
|
|
291 |
<div class="bd"> |
|
|
292 |
<ul class="examples"> |
|
|
293 |
|
|
|
294 |
|
|
|
295 |
<li data-description="A simple multiple file uploader with progress tracking"> |
|
|
296 |
<a href="uploader-multiple.html">Simple Multiple Files Uploader with Progress Tracking</a> |
|
|
297 |
</li> |
|
|
298 |
|
|
|
299 |
|
|
|
300 |
|
|
|
301 |
<li data-description="A multiple file uploader with HTML5 Drag-and-Drop Support"> |
|
|
302 |
<a href="uploader-dd.html">Multiple Files Uploader with HTML5 Drag-and-Drop Support</a> |
|
|
303 |
</li> |
|
|
304 |
|
|
|
305 |
|
|
|
306 |
|
|
|
307 |
<li data-description="A multiple file uploader that submits additional POST vars with each file and receives data from the server"> |
|
|
308 |
<a href="uploader-data.html">Multiple Files Uploader with POST Variables and Server Data Retrieval</a> |
|
|
309 |
</li> |
|
|
310 |
|
|
|
311 |
|
|
|
312 |
</ul> |
|
|
313 |
</div> |
|
|
314 |
</div> |
|
|
315 |
|
|
|
316 |
|
|
|
317 |
|
|
|
318 |
</div> |
|
|
319 |
</div> |
|
|
320 |
</div> |
|
|
321 |
</div> |
|
|
322 |
|
|
|
323 |
<script src="../assets/vendor/prettify/prettify-min.js"></script> |
|
|
324 |
<script>prettyPrint();</script> |
|
|
325 |
|
|
|
326 |
<script> |
|
|
327 |
YUI.Env.Tests = { |
|
|
328 |
examples: [], |
|
|
329 |
project: '../assets', |
|
|
330 |
assets: '../assets/uploader', |
|
|
331 |
name: 'uploader', |
|
|
332 |
title: 'Uploader', |
|
|
333 |
newWindow: '', |
|
|
334 |
auto: false |
|
|
335 |
}; |
|
|
336 |
YUI.Env.Tests.examples.push('uploader-multiple'); |
|
|
337 |
YUI.Env.Tests.examples.push('uploader-dd'); |
|
|
338 |
YUI.Env.Tests.examples.push('uploader-data'); |
|
|
339 |
|
|
|
340 |
</script> |
|
|
341 |
<script src="../assets/yui/test-runner.js"></script> |
|
|
342 |
|
|
|
343 |
|
|
|
344 |
|
|
|
345 |
</body> |
|
|
346 |
</html> |