forked from moxiecode/plupload
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.html
More file actions
244 lines (210 loc) · 7.22 KB
/
error.html
File metadata and controls
244 lines (210 loc) · 7.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" href="../examples/css/plupload.queue.css" type="text/css" media="screen" />
<title>Plupload - Queue widget example</title>
<style type="text/css">
body {background: #9A7C5F;}
</style>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("jquery", "1.3");
</script>
<script type="text/javascript" src="../src/javascript/gears_init.js"></script>
<script type="text/javascript" src="http://bp.yahooapis.com/2.4.21/browserplus-min.js"></script>
<!-- Load source versions of the plupload script files -->
<script type="text/javascript" src="../src/javascript/plupload.js"></script>
<script type="text/javascript" src="../src/javascript/plupload.gears.js"></script>
<script type="text/javascript" src="../src/javascript/plupload.silverlight.js"></script>
<script type="text/javascript" src="../src/javascript/plupload.flash.js"></script>
<script type="text/javascript" src="../src/javascript/plupload.browserplus.js"></script>
<script type="text/javascript" src="../src/javascript/plupload.html4.js"></script>
<script type="text/javascript" src="../src/javascript/plupload.html5.js"></script>
<script type="text/javascript" src="../src/javascript/jquery.plupload.queue.js"></script>
<script type="text/javascript" src="http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js"></script>
<script>
$(function() {
// Setup flash version
$("#flash_uploader").pluploadQueue({
// General settings
runtimes : 'flash',
url : 'error.php',
unique_names : true,
chunk_size : '1mb',
filters : [
{title : "Zip files", extensions : "zip"}
],
// Flash settings
flash_swf_url : '../js/plupload.flash.swf',
setup : setup
});
// Setup gears version
$("#gears_uploader").pluploadQueue({
// General settings
runtimes : 'gears',
url : 'error.php',
unique_names : true,
chunk_size : '1mb',
filters : [
{title : "Zip files", extensions : "zip"}
],
setup : setup
});
// Setup silverlight version
$("#silverlight_uploader").pluploadQueue({
// General settings
runtimes : 'silverlight',
url : 'error.php',
unique_names : true,
chunk_size : '1mb',
filters : [
{title : "Zip files", extensions : "zip"}
],
// Silverlight settings
silverlight_xap_url : '../js/plupload.silverlight.xap',
setup : setup
});
// Setup html5 version
$("#html5_uploader").pluploadQueue({
// General settings
runtimes : 'html5',
url : 'error.php',
unique_names : true,
chunk_size : '1mb',
filters : [
{title : "Zip files", extensions : "zip"}
],
setup : setup
});
// Setup browserplus version
$("#browserplus_uploader").pluploadQueue({
// General settings
runtimes : 'browserplus',
url : 'error.php',
unique_names : true,
chunk_size : '1mb',
filters : [
{title : "Zip files", extensions : "zip"}
],
setup : setup
});
// Setup browserplus version
$("#html4_uploader").pluploadQueue({
// General settings
runtimes : 'html4',
url : 'error.php',
unique_names : true,
chunk_size : '1mb',
filters : [
{title : "Zip files", extensions : "zip"}
],
setup : setup
});
function setup(uploader) {
uploader.bind('StateChanged', function() {
if (uploader.state == plupload.STARTED) {
// If status is 103 then try uploading to an invalid domain
if ($('#errorcode').val() == "103") {
uploader.settings.url = 'http://www.moxiecode.com/error.php?code=' + $('#errorcode').val();
} else {
uploader.settings.url = 'error.php?code=' + $('#errorcode').val();
}
}
});
uploader.bind('Error', function(up, err) {
console.log('Error', err);
});
function handleResponse(up, file, response) {
var code = parseInt($('#errorcode').val(), 10), err = {code : code};
if (response.chunks) {
console.log('ChunkUploaded', file, response);
} else {
console.log('FileUploaded', file, response);
}
switch (code) {
case plupload.GENERIC_ERROR:
err.message = plupload.translate('Generic error.');
err.file = file;
break;
case plupload.HTTP_ERROR:
// Don't trigger this let the server do it
return;
case plupload.IO_ERROR:
err.message = plupload.translate('IO error.');
err.file = file;
break;
case plupload.SECURITY_ERROR:
err.message = plupload.translate('Security error.');
err.file = file;
break;
case 101:
if (file == up.files[1]) {
err.code = plupload.GENERIC_ERROR;
err.message = plupload.translate('Generic error.');
err.file = file;
} else
return;
break;
case 102:
if (file == up.files[1] && response.chunk == 1) {
err.message = plupload.translate('Fake chunk error.');
err.file = file;
} else
return;
break;
case 0:
return;
default:
err.message = plupload.translate('User specific error.');
err.details = plupload.translate('Some custom data.');
err.file = file;
}
uploader.trigger('Error', err);
};
uploader.bind('ChunkUploaded', handleResponse);
uploader.bind('FileUploaded', handleResponse);
};
});
</script>
</head>
<body>
<form method="post" action="../examples/dump.php">
<h1>Error handling test page</h1>
<div>
Error to fake:
<select id="errorcode">
<option value="0">No error</option>
<option value="-100">GENERIC_ERROR</option>
<option value="-200">HTTP_ERROR</option>
<option value="-300">IO_ERROR</option>
<option value="-400">SECURITY_ERROR</option>
<option value="100">Custom error</option>
<option value="101">Fail on second file</option>
<option value="102">Fail on second chunk in second file</option>
<option value="103">Invalid domain</option>
</select>
</div>
<div style="float: left; margin-right: 20px">
<h3>Flash runtime</h3>
<div id="flash_uploader" style="width: 450px; height: 330px;">You browser doesn't have Flash installed.</div>
<h3>Gears runtime</h3>
<div id="gears_uploader" style="width: 450px; height: 330px;">You browser doesn't have Gears installed.</div>
</div>
<div style="float: left; margin-right: 20px">
<h3>Silverlight runtime</h3>
<div id="silverlight_uploader" style="width: 450px; height: 330px;">You browser doesn't have Silverlight installed.</div>
<h3>HTML 5 runtime</h3>
<div id="html5_uploader" style="width: 450px; height: 330px;">You browser doesn't support native upload. Try Firefox 3 or Safari 4.</div>
</div>
<div style="float: left; margin-right: 20px">
<h3>BrowserPlus runtime</h3>
<div id="browserplus_uploader" style="width: 450px; height: 330px;">You browser doesn't have BrowserPlus installed.</div>
<h3>HTML4 runtime</h3>
<div id="html4_uploader" style="width: 450px; height: 330px;">You browser doesn't have a HTML 4 browser.</div>
</div>
<br style="clear: both" />
<input type="submit" value="Send" />
</form>
</body>
</html>