Uploader - Wait for upload to complete


The upload widget included with dhtmlxForm is very nice. I have one small issue I’ve been having a problem with and I’m not sure of the best way to fix it. I have a form where a user can fill out a number of fields and also select additional files to upload. At the bottom of the form I have a button to submit the form. When this button is pressed I attempt to upload the files in the upload widget in case the user didn’t start the process using upload widget itself.

However formUploader.upload() is asynchronous so the Javascript won’t pause for the files to upload. This can cause problems where after uploading I want to know the names of the files which have been uploaded but because .upload() hasn’t finished .getData() won’t return any file names. I can use .getStatus() to see if the upload is complete but I was wondering if there was some graceful way to just pause until all files are successfully uploaded before proceeding?

   myform.attachEvent("onButtonClick", function(id) {
     if(id == "uploadbtn") {
       if(myform.validate() == true)
         textSelected = myTree.getSelectedItemText();

         var parents = myTree.getAllItemsWithKids();
         if (parents.indexOf(textSelected.toLowerCase()) >= 0) {
           formUploader.upload(); //Attempt to upload in case user didn't start process

          formUploader.getStatus(); // This will tell if upload is done
          //How can I wait for the upload to be complete before proceeding?

          var uploadedData = formUploader.getData(); //Upload is done.. Do stuff


please provide completed demo including all corresponding js/css files,
browser/os details and working mode (or text from uploader’s title screen)

direct link also an option

you can send demo/info to support@dhtmlx.com