views:

14

answers:

1

I have a form which is using swfupload with the jquery plugin.

I have some required fields which should be filled before I allow upload.

So I add a handler to file_dialog_complete_handler

Somethings like,

  file_dialog_complete_handler = function(dom_el){
   alert(10);
   dom_el.cancelUpload();
   return false;
  }

This doesnt work as I dont know where is the cancelUpload defined.

A: 

Hmmm, I think I would approach this a different way. If you require other form fields to be filled-in/validated before the user can upload files, then start the SWFUload with the parameter button_disabled : true. This will make it impossible to press the button to select files and queue-up/upload files.

Then, you can set a handler on your form inputs (onchange, onkeyup, etc.) that checks the data in your form and if it checks out, then use the method: [your SWFU object].setButtonDisabled(false) which will enable the button, and your user can now upload files.

This is the method I use to accomplish what you're after.

cancelUpload is another method on the SWFUpload object and is documented here: http://demo.swfupload.org/Documentation/#cancelUpload

Since you've tagged this as jQuery, you might be interested in the jQuery.swfupload plugin that makes like very easy for you. Check it out here: http://github.com/ifunk/swfupload-jquery-plugin

I hope this helps.

mkoistinen