Plupload 逆序上传
Plupload reverse order of uploading
我想在 plupload 中颠倒上传文件的顺序。
尝试过:
FilesAdded: function(up, files) {
files = files.reverse();
plupload.each(files, function(file) {
up.start();
});
},
但它的作用是一样的。
我想颠倒文件上传的顺序。
例如:
用户选择:Img1,Img2,Img3,Img4
Plupload 将上传:Img4,Img3,Img2,Img1
有什么方法可以做到吗?
非常感谢!
FileList object not appear to have .reverse()
method . Try utilizing .slice()
, .call()
to convert files
to Array
, then call .reverse()
method on array of File
objects. See how does Array.prototype.slice.call() work?
FilesAdded: function(up, files) {
var reversed = Array.prototype.slice.call(files).reverse();
plupload.each(reveresed, function(file) {
up.start();
});
},
$("input").on("change", function(e) {
var files = e.target.files;
var reversed = Array.prototype.slice.call(files).reverse();
console.log(Array.prototype.slice.call(files), reversed);
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
</script>
<input type="file" multiple />
jsfiddle http://jsfiddle.net/531ozmn2/
我想在 plupload 中颠倒上传文件的顺序。
尝试过:
FilesAdded: function(up, files) {
files = files.reverse();
plupload.each(files, function(file) {
up.start();
});
},
但它的作用是一样的。
我想颠倒文件上传的顺序。
例如:
用户选择:Img1,Img2,Img3,Img4
Plupload 将上传:Img4,Img3,Img2,Img1
有什么方法可以做到吗?
非常感谢!
FileList object not appear to have .reverse()
method . Try utilizing .slice()
, .call()
to convert files
to Array
, then call .reverse()
method on array of File
objects. See how does Array.prototype.slice.call() work?
FilesAdded: function(up, files) {
var reversed = Array.prototype.slice.call(files).reverse();
plupload.each(reveresed, function(file) {
up.start();
});
},
$("input").on("change", function(e) {
var files = e.target.files;
var reversed = Array.prototype.slice.call(files).reverse();
console.log(Array.prototype.slice.call(files), reversed);
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
</script>
<input type="file" multiple />
jsfiddle http://jsfiddle.net/531ozmn2/