forked from mailru/FileAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
support.html
110 lines (90 loc) · 2.67 KB
/
support.html
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="user-scalable=no, width=400, initial-scale=0.8, maximum-scale=0.8" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="yes" />
<meta name="format-detection" content="email=no" />
<meta name="HandheldFriendly" content="true" />
<title>FileAPI :: Support</title>
<script>
// Объект настройки
var FileAPI = {
debug: true, // режим отладки
staticPath: './' // путь до флешек
};
</script>
</head>
<body>
<div>Single:</div>
<div class="js-fileapi-wrapper"></div><input id="singleFile" type="file" /></div>
<br/>
<div>Multiple:</div>
<div class="js-fileapi-wrapper"><input id="multipleFiles" type="file" multiple /></div>
<div id="log" style="border: 1px solid red; padding: 3px; margin: 2px"></div>
<div id="__console" style="font-size: 12px; color: #333;"></div>
<script>
window.console = {
_div: document.getElementById('__console'),
log: function (){
this._div.innerHTML += [].join.call(arguments, ' ') + '<br/>';
},
error: function (){
this._div.innerHTML += '<span style="color: red">';
this.log.apply(this, arguments);
this._div.innerHTML += '</span>';
}
};
</script>
<script src="./FileAPI.min.js"></script>
<script>
(function (){
function _log(txt){
log.innerHTML = txt + '<br/>' + log.innerHTML;
}
function _uploadFiles(files){
if( files.length ){
FileAPI.each(files, function (file){
_log(' -> name: '+file.name+', type: '+file.type+', size: '+file.size);
FileAPI.Image(file).get(function (err, image){
if( err ){
_log('error: '+file.name+' -- '+err)
}
else {
document.body.appendChild(image);
}
});
});
FileAPI.upload({
url: 'http://rubaxa.org/FileAPI/server/ctrl.php',
files: { test: files },
complete: function (err){
if( err ){
_log('upload failed: '+err)
} else {
_log('files uploaded!');
}
}
});
}
else {
_log('Files not selected');
}
}
FileAPI.event.on(singleFile, 'change', function (){
var files = FileAPI.getFiles(singleFile);
_uploadFiles(files);
});
FileAPI.event.on(multipleFiles, 'change', function (){
var files = FileAPI.getFiles(multipleFiles);
_uploadFiles(files);
});
FileAPI.each(FileAPI.support, function (val, key){
_log('FileAPI.support.'+key+': '+val);
});
})();
</script>
</body>
</html>