Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
115
WebUpload and Postback
posted

I'm trying to create a web page with form fields and a WebUpload control..   It's a support forum kind of thing that allows the user to enter details and add files as attachments.    

A few questions..   

If you select a few files to attach and then do something else on the page that causes a postback, the WebUpload control loses its contents and reverts back to original state..  is there a way of retaining the content ?

How can I use one button on the page to do a postback and have it upload the files at that time, not as a separate operation.. the files are going into the DB.

Parents
  • 3995
    Offline posted

    Hello Adrian,

    You can bind to submit event of your form and prevent the submitting. At that point you can access current status of the file upload - $("#WebUpload2").igUpload("getFileInfoData"); and store those files, once that's done you could invoke submit method of the form manually.

    Here's what I did in order to upload all my pending files:

    $("#form1").submit(function (e) {
        e.preventDefault();
        var that = this;
        var fileInfoData = $("#WebUpload2").igUpload("getFileInfoData");
        fileInfoData.filesInfo.forEach(function (file) {
            $("#WebUpload2").igUpload("startUpload", file.formNumber);
        });
        setTimeout(function () {
            that.submit();
        }, 0);
    });
     

    Please let me know if this helps, or you need more details.

Reply Children