업로드 지원 스크립트(upload-support.js) 추가
parent
ddd92af97b
commit
772e9ef622
@ -0,0 +1,23 @@
|
||||
function uploadSupport(selector) {
|
||||
let input = $(selector);
|
||||
if (!input)
|
||||
throw "Element not found: " + selector;
|
||||
|
||||
let fileset = new Dataset({
|
||||
keymapper: info => info.id
|
||||
});
|
||||
|
||||
input.change(function() {
|
||||
var files = $(this).get(0).files,
|
||||
length = files.length,
|
||||
array = []
|
||||
for (var i = 0; i < length; ++i) {
|
||||
var file = files[i];
|
||||
file.id = "file-" + new Date().getTime() + "-" + i;
|
||||
file.url = (window.URL || window.webkitURL).createObjectURL(file);
|
||||
array.push(file);
|
||||
}
|
||||
fileset.setData(array);
|
||||
});
|
||||
return fileset;
|
||||
}
|
Loading…
Reference in New Issue