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