Reputation: 11271
I want to reverse order of uploading file in plupload.
Tried:
FilesAdded: function(up, files) {
files = files.reverse();
plupload.each(files, function(file) {
up.start();
});
},
But it does the same.
I want to reverse the order of file uploadin.
Eg:
User selects: Img1,Img2,Img3,Img4
Plupload will upload: Img4,Img3,Img2,Img1
Is there any method to do this?
Thank you so much!
Upvotes: 0
Views: 440
Reputation: 1
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/
Upvotes: 1