-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathutils.js
More file actions
30 lines (25 loc) · 754 Bytes
/
utils.js
File metadata and controls
30 lines (25 loc) · 754 Bytes
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
function handleFileSelect(evt, imgloader, cvs) {
var files = evt.target.files; // FileList object
// Loop through the FileList and upload the first image encountered.
for (var i = 0, f; f = files[i]; i++) {
// Only process image files.
if (!f.type.match('image.*')) {
continue;
}
else {
uploadImage( f, cvs );
}
}
function uploadImage( file, cvs ) {
var fr;
if (typeof window.FileReader !== 'function') {
write("The file API isn't supported on this browser yet.");
return;
}
fr = new FileReader();
fr.onload = function() {
imgloader.loadImage(fr.result, cvs);
};
fr.readAsDataURL(file);
}
}