zoukankan      html  css  js  c++  java
  • ajax 上传多个附件,注意的点

     上传标签:

     <input type="file" class="add" multiple onchange="upLoadChange(this)"/>

     js代码:

    function upLoadChange(e){
        var formData = new FormData();
        for (var i = 0; i < e.files.length; i++) {
             //注意这里必须用 【"file"+i】,如果直接【"file"】,会认为同一个文件并且覆盖,导致上传了多个一样的文件
          formData.append("file"+i, e.files[i]);
        }
        $.ajax({
           type: "post",
            url: "/FileUpload/Save?BizID=@Model.BizID&BizType= @Model.BizTableName",
           processData: false,
            contentType: false,
            data: formData,
            dataType: "json",
            cache: false,
            success: function (data) {
     
         }
     
         });
    }

    注意点:这里必须用 【"file"+i】,如果直接【"file"】,会认为同一个文件并且覆盖,导致上传了多个一样的文件

  • 相关阅读:
    algorithm,ds,Skew heap
    python,file,os,shutil
    python,pickle,serialize
    algorithm,ds,leftist heap
    shell,chapter 2
    shell,chapter 1
    shell,Introduction to shell
    signal and slot in pyside
    python,cron,gae,bae
    python,mysql,sql,mysqldb
  • 原文地址:https://www.cnblogs.com/luyiwei/p/11163922.html
Copyright © 2011-2022 走看看