The Error
I've been working on a YUI Uploader integration for the past several hours, the last couple of which were spent troubleshooting the JavaScript error: "uncaught exception: Error calling method on NPObject! [plugin exception: "TypeError: Error #1009"]". This error would be raised as soon as the upload was started, and didn't appear to be related to any of my JavaScript functions.
What Caused It
The cause for me was actually very very simple, and can be reproduced on Yahoo's multiple file upload example. If you set the number of simultaneous uploads higher than the number of files you have in the queue, the flash uploader will try to perform file uploads on object that don't exist.
How I Fixed It
I added a test to make sure the number of files being uploaded was not smaller then the number of simultaneous uploads. Using YUI example mentioned earlier, here is the change needed to their upload function:
function upload() { if (fileList != null) { // Count the number of total files numberOfFiles = 0; for (i in fileList){numberOfFiles++}; // Set the default limit simUploadLimit = parseInt(document.getElementById("simulUploads").value) // Test if default is larger, if so use the number of files as the limit simUploadLimit = numberOfFiles < simUploadLimit ? numberOfFiles : simUploadLimit; uploader.setSimUploadLimit(simUploadLimit); uploader.uploadAll("http://www.yswfblog.com/upload/upload_simple.php","POST",null,"Filedata"); } }

22 Comments
Thanks a lot for saving me a couple of hours of trying to track this down.
Thanks for the information! There are a lot of incorrect solutions out there.
Thanks a million, that did the trick. You are a Java JEDI!!
Thank UUUUUUUUU
Thanks!
I used this code for a default simultaneous upload of 2:
var simUp = Math.min(2, fileList.length);
Thank for provide such a to the point help to resolve my problem.
Thank you very very much. by the way, when I run my page in IE, the uploadCompleteData event can't be triggered, but uploadComplete is ok. And with firefox, it also work well. Do you know the reason, thank you.
wow, nice job figuring that out! and caleb, nice code-shortening job there. :) thanks a bunch for sharing, dudes.
actually, it looks like fileList.length is undefined, caleb!
Thank you guys very much, you saved a loooottt of debugging time.
You Sir are the man!
Thank you! like everyone above said, you saved me a lot of head scratching! :)
Like everyone else above, thanks for posting this. I love the Internet. :)
Thanks for posting this. Saved a lot of time.
SWF should do the check in the future.
SUPER !!!
BRAVO !!!
No1 !!!
Thanks. You saved me a lot of time.
Thank you. Good job!
I'm glad you posted this. THX
Thanks a lot!!!!!!!
Thank you very much. I am implementing upload multi-files that base on YUI uploader and getting this exception but I can not reproduce since I am not familiar with FLASH. Right now I can fix it.
Thank you very much. I am implementing upload multi-files that base on YUI uploader and getting this exception but I can not reproduce since I am not familiar with FLASH. Right now I can fix it..
clavier arabe http://www.clavierarabes.com/ clavier arabe clavier arabe clavier arabe clavier arabe clavier arabe clavier arabe clavier arabe clavier arabe
Submit a Comment