<form id= "uploadForm">  

    <>指定文件名: <input type="text" name="filename" value= ""/></>  

    <>上传文件: <input type="file" name="file"/></ p>  

    <input type="button" value="上传" onclick="doUpload()" />  

</form>  

  • JS:

function doUpload() {  

var formData = new FormData($( "#uploadForm" )[0]);  

     $.ajax({  

          url: 'xxx' ,                  --------------这里是请求的接口

          type: 'POST',              

          data: formData,  

          async: false,  

          cache: false,  

          contentType: false,  

          processData: false,  

          success: function (returndata) {  

              alert(returndata);  

          },  

          error: function (returndata) {  

              alert(returndata);  

          }  

     });  

相关文章:

  • 2021-11-15
  • 2022-01-06
  • 2022-02-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-26
  • 2022-12-23
相关资源
相似解决方案