Thursday, February 6, 2014

FileUploadControl using Ajaxcalls

We can submit the form data like files or any other data like textbox fields like this(Using simple ajax call):

var formdata = new FormData( );
//Here i am passing the form data like this
var ComposeEmailReq = { MailFrom: MailFrom, MailTo: MailTo, ReplyTo: ReplyTo, Subject: Subject, Body: Body, Forwardattachment: details,CC:cc,BCC:bcc};

            //file uploading using ajax.
            formdata.append("Details", JSON.stringify(ComposeEmailReq));
            for (var i = 0; i < $("#fupAttachments")[0].files.length; i++) {
                //we can appending the files like this
                formdata.append("Attachments", $("#fupAttachments")[0].files[i]);
            }