I am using multiple uploadify instances on single page. But the problem is that when I submit the form,form gets submitted before the upload of all the files.
I tried event.preventDefault(); to prevent the form submission before the image upload. but I am not getting the solution. Please suggest me some way by which I can prevent the form submission until all the uploadify files gets uploaded.
Here is my function
$("#add_facility_form .form-submit").click(function(event){
event.preventDefault();
$('#gallary').uploadifyUpload();
$('#brochures').uploadifyUpload();
$('#award_logo').uploadifyUpload();
$('#acc_logo').uploadifyUpload();
$('#file_upload').uploadifyUpload();
$("#add_facility_form").submit();
});
I would suggest using classes for your file uploads – will reduce your jQuery code .. for example …
Then your jQuery becomes :
Then when you initialise the uploadify elements add an
onCompletemethod to keep a track of the completed uploads :Then create a variable for keeping a track of the completed uploads then in the
incrementUploadedCountfunction check that all have been complete, if they have submit the form