views:

5870

answers:

3

Hi

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?

A: 

I don't understand... uploadify by default removes a file from the queue when it has uploaded successfull, why are you trying to remove it?

+12  A: 

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.

Jimbo
Ill add another condition here. whatever button you use as your upload button needs to have an id otherwise, while the upload will happen, no events get fired.
schmidty
Thanks for posting this, really helped!
Victor
So glad I found this -- `onComplete` doesn't fire unless you return something, anything at all, just not an empty document!
Jeriko
I would give you +1000 if I could. Thanks man.
Claudio Redi
+1  A: 

Hi,

I have been using uploadify in an .NET MVC Application as well. And I know exactly what you mean. All I did to fix your problem was make my controller's action return a JSON response and I could parse it back on the onComplete event. The only time I had a problem with events were if the actual file is missing (as I display thumbnails of the image) on the response.

yveslebeau