onComplete and onCompleteAll events failing to fire when using Uploadify

Jimbo picture Jimbo · Sep 9, 2009 · Viewed 17.3k times · Source

I have been using uploadify (www.uploadify.com) to upload images to my website, and it works beautifully until you try to expand on it a little. Im trying to get it to remove a queued up file from the list once that file has been uploaded. To do this, you would initialize uploadify as such:

            $("#fileUpload").uploadify({
            'uploader': '/scripts/uploadify.swf',
            'cancelImg': '/images/cancel.png',
            'script': '/Album/Manage/',
            'fileDesc': 'Image Files',
            'fileExt': '*.jpg;*.jpeg;*.gif;*.png',
            'multi': true,
            'auto': false,
            'simUploadLimit': 3,
            'scriptData': {'album_id':'7'},
            onComplete: function(event, queueID, fileObj, response, data){
                alert(queueID); 
            }
        });

In the above example, you'd replace alert(queueID) with $("#fileUpload").uploadifyCancel(queueID) - I just have the alert to let me know when the event fires - which never happens. I have used IE and Firefox and no difference in either. Does anyone have any experience with this?

Answer

Jimbo picture Jimbo · Sep 19, 2009

RESOLVED!

Right, i gather this is about the only article on the entire internet (including the Uploadify documentation and support pages) that describes the quirks of Uploadify in a .Net MVC application

Having done extensive testing, I have seen that:

  1. If the script that accepts the uploaded files (specified in the uploadify initialize code as 'script': '/Album/Manage/') does not return anything, Uploadify's response events dont fire - I gather that an error stops it processing. My script was an action in a controller whose return type was string. If there was an error, it returned the error as a string, otherwise returned nothing. All I did to fix this was make it return 'OK' if nothing went wrong instead of nothing.

  2. Passing script data (specified in the uploadify initialize as 'scriptData': {'album_id':'7'}) the way I was doing it was ALSO causing an error - I havent worked out why (and RonnieSan, the father of Uploadify, didnt seem to see anything wrong with it) so if anyone does know maybe they can respond to this post

  3. You MUST NOT put single quotes around the event handlers e.g. onComplete: function(event, queueID, fileObj, response, data) { ... }

Hope this helps - if anyone needs assistance with .Net MVC implementation, just drop me a message.