I would like a status like "uploading file 1 of 4" - only counting the files in the current queue.
I've tried this, but it shows more than the current queue successfull uploads, and the files_queued shows the files left in the queue.
function uploadStart(fileObj) {
try {
var progress = new FileProgress(fileObj, this.customSettings.progressTarget);
progress.SetStatus("Uploading");
progress.ToggleCancel(true, this);
var suploads = upload1.getStats().successful_uploads;
var fqueued = upload1.getStats().files_queued;
document.getElementById('uploadcount').innerHTML = "Uploading file " + suploads + " of " + fqueued;
}
catch (ex) {}
return true;
}
What is the correct way of displaying this? Any help would be greatly appreciated.
Counters
There are probably several ways to do this and it depends on how you want it to behave but the easiest way is probably this:
Use fileDialogComplete to get the count of the files queued. It's available as one of the parameters to the event (see the Docs). Use the customSettings location to store the total queued count.
Then using the startUpload and an upload count in customSettings to track which upload you are one.
The getStats shows the current status of SWFUpload so files_queued will go down every time successful_uploads or upload_errors goes up.
Something like this:
function fileDialogComplete(numFileSelected, numFilesQueued) {
this.customSettings.filesQueuedCount += numFilesQueued;
}
function uploadStart(file) {
this.customSettings.fileUploadNumber++;
document.getElementById('uploadcount').innerHTML = "Uploading file " + this.customSettings.fileUploadNumber + " of " + this.customSettings.filesQueuedCount;
}
it works
Thats excellent - it works like a charm. I just had to figure out to set the variables to zero like this first:
custom_settings : {
fileUploadNumber : 0,
filesQueuedCount : 0
},
Thank you very much!