Plupload逆向上传顺序

时间:2015-04-24 06:04:04

标签: javascript jquery plupload

我想在plupload中颠倒上传文件的顺序。

尝试:

FilesAdded: function(up, files) {
    files = files.reverse();
    plupload.each(files, function(file) {
        up.start();
    });
},

但它也是如此。

我想颠倒上传文件的顺序。

例如:

用户选择:Img1,Img2,Img3,Img4

Plupload将上传:Img4,Img3,Img2,Img1

有没有办法做到这一点?

非常感谢你!

1 个答案:

答案 0 :(得分:1)

FileList对象似乎没有.reverse()方法。尝试使用.slice().call()files转换为Array,然后在.reverse()个对象的数组上调用File方法。见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 />
&#13;
&#13;
&#13;

jsfiddle http://jsfiddle.net/531ozmn2/