Hi Guys!
Today i noticed that swfupload sorting the files really crazy!
The last file i choose in the "Select File" Dialog, is allways the first file that he handels, and then swfupload handles the files alphabetical. Why this?
How can i "easily" change this behavior and is it changeable?
thank you!
regards
November 5, 2008 - 10:25am
This is a windows thing. When you select many files the entire group is listed in order from top down (the ordering depends on your view of the files, mine are ordered by type). Then the file that was under the pointer when the selection was finished is "selected" and is first.
It's not a SWFUpload thing. It's a windows thing and happens in all explorer windows.
November 5, 2008 - 1:44pm
i tested it now with my linux and my vista machine, and yes it works fine there, the problem is really xp...
thank you gyphie!
November 5, 2008 - 8:48pm
I noticed it also. What I did to fix it is reorder the queue.
You can use the file object properties for correctly reorder the files by creation date (very appropriate for pictures from digital cameras) or by name alphabetically.
Create an array of all the selected files, reorder this array using the sort javascript method for example, and then upload the files in this ordered array one by one form position 0 to n.
November 6, 2008 - 7:40am
thank your for your tipp, today i tried some different things but it won't work.
maybe i'm to stupid, but i tried so much and allways it is to "late" to sort it, because the upload of the first file has allready start, and then it handles file by file.
regards
November 6, 2008 - 11:36am
If you want to re-sort the queue you then have to do your own manual queue management.
You can upload files in any order using startUpload(file_id). If you keep a sorted array of file objects you should be able to go through it in the order you wish.
I think the harder part it updating the UI and inserting newly queued files between the other UI elements.
Also note that you may confuse a user who already has a long list and then queues one more file that it is added to the list somewhere off-screen. They may think their file wasn't added at all.
-------------
Something like this might work (I've not shown the queueing, sorting, cancel/error handling, just manual queue management).
var orderedFileQueue = [ /* already sorted file objects */];
function doUpload_Click() {
if (orderedFileQueue.length > 0) {
var file = orderedFileQueue.shift();
swfu.startUpload(file.id);
}
}
function uploadComplete(file) {
if (orderedFileQueue.length > 0) {
var nextFile = orderedFileQueue.shift();
this.startUpload(nextFile.id);
}
}
May 3, 2010 - 2:14am
Thanks in advance. Can u please provide me some code to sort the file names