Formdata Uploading Files

Source: Internet
Author: User

The selected XML needs to be uploaded to the background, converted to htmlhtml via XSLT:  <form id= "Uploadform" enctype= "Multipart/form-data" >   <input Type= "File" Name= "testfile" value= "Select File" >   <input type= "button" value= "Add" id= "BTN" >  </form> Js:<script type= "Text/javascript" >    var formData = new FormData ($ ("#uploadForm") [0]);          $.ajax ({               url:url,               type: ' POST ',               data:formdata,               async:false,               cache:false,               contentType: False,               Processdata:false,               success:function (data) {        ...             },               error:function (returndata) {                   alert ("Error");}          );   </script>

  

Here are a few things to note:

    • processDataSet to false . Because the data value is an FormData object, you do not need to process the data.
    • <form>tag to add a enctype="multipart/form-data" property.
    • cacheSet to false , the upload file does not need to be cached.
    • contentTypeSet to false . This is set to false because it is an <form> object constructed by a form, and the FormData property has already been declared enctype="multipart/form-data" .

After uploading, the server-side code needs to use the file get file input stream object from the query parameter name, because <input> it is declared in name="file" .



Formdata Uploading Files

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.