weixin_33733810 2017-10-06 14:23 采纳率: 0%
浏览 33

Ajax文件上传ASP.NET MVC [重复]

This question already has answers here:
                </div>
            </div>
                    <div class="grid--cell mb0 mt4">
                        <a href="/questions/2320069/jquery-ajax-file-upload" dir="ltr">jQuery Ajax File Upload</a>
                            <span class="question-originals-answer-count">
                                (24 answers)
                            </span>
                    </div>
                    <div class="grid--cell mb0 mt4">
                        <a href="/questions/29293637/how-to-append-whole-set-of-model-to-formdata-and-obtain-it-in-mvc" dir="ltr">How to append whole set of model to formdata and obtain it in MVC</a>
                            <span class="question-originals-answer-count">
                                (3 answers)
                            </span>
                    </div>
            <div class="grid--cell mb0 mt8">Closed <span title="2017-10-06 21:48:47Z" class="relativetime">2 years ago</span>.</div>
        </div>
    </aside>

I need to upload multiple files along with other 2D Arrays. my code is below, but which is not woking. when i remove the file upload or the array data(addProcurementModel ) from code then it is working fine.

JS

   var fileUpload = $("#flpFileType1").get(0);
    var files = fileUpload.files;
    var fileData = new FormData();
    for (var i = 0; i < files.length; i++) {
        fileData.append(files[i].name, files[i]);
    }


    var addProcurementModel = {
        Suppliers: suppliers,
        ItemSpecifications: itemSpecifications,
        PurchaseJustification: purchaseJustification

    };

    $.ajax({
        type: "POST",
        url: "/Procurement/AddProcurement",
        data: { AddProcurementModel: addProcurementModel, FileData: fileData },
        cache: false,
        processData: false,
        dataType: 'json',
        contentType: false,

        success: function (sucess) {
            if(sucess.message==true)
            {
               //do something
            }

        }
    });

Controller

   [HttpPost]
    public ActionResult AddProcurement(AddProcurementModel addProcurementModel)
    {
        HttpFileCollectionBase files = Request.Files;
        foreach (string file in files)
        {
            var fileContent = Request.Files[file];


        }
   }
</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料