Question

I'm using the YUI 2 Uploader to upload some files. My users will be uploading more than one file, so I want to use YUI Uploader's 'file queue'. That is all working successfully. I disable the uploader when the files are uploading, so people can't add new files to the queue once they start uploading the files.

I want to do something (in JavaScript) when all the files have been uploaded. The YUI Uploader has signals for when certain files are uploaded, but not when all files in the queue have been uploaded. Is there some way to detect when all the files have been uploaded?

Was it helpful?

Solution

Keep an object (or array) of files & in the uploadComplete handler remove whichever file just finished. If there are none left call your upload finalize function.

Example implementation here, http://tivac.com/upload/upload.js It has some bugs but solves this particular problem.

OTHER TIPS

Create an eventhandler for the uploadcomplete event. Take a look at the yui uploader documentation: http://developer.yahoo.com/yui/docs/YAHOO.widget.Uploader.html

http://developer.yahoo.com/yui/examples/uploader/uploader-advanced-queue.html

function onUploadComplete(event) {
        rowNum = fileIdHash[event["id"]];
        prog = Math.round(100*(event["bytesLoaded"]/event["bytesTotal"]));
        progbar = "<div style='height:5px;width:100px;background-color:#CCC;'><div style='height:5px;background-color:#F00;width:100px;'></div></div>";
        singleSelectDataTable.updateRow(rowNum, {name: dataArr[rowNum]["name"], size: dataArr[rowNum]["size"], progress: progbar});
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top