【问题标题】:send multiple image + multiple array object to controller in asp.net mvc在asp.net mvc中将多个图像+多个数组对象发送到控制器
【发布时间】:2020-04-20 06:05:10
【问题描述】:
 function GetConfirmMedicine() {
            var PharmacyProductList = new Array();

            var medObj = JSON.parse(localStorage.getItem("phrmacyCart"));
            for (var i = 0; i < medObj.length; i++) {
                PharmacyProductList.push({
                    ProductID: medObj[i].ProductID,
                    ProductTitle: medObj[i].ProductTitle,
                    Quantity: medObj[i].Quantity,
                    TotalPrice: medObj[i].MedicinTotalPrice

                });
            }
            model = {
                FullName: $('#FullNametxt').val(),
                ContactNumber: $('#ContactNumbertxt').val(),
                Address: $('#Addresstxt').val(),
               // ImagePhath: $('#uploadFiletxxt')[0],

                PharmacyProductList: PharmacyProductList
            };
            return model;
        }

        function ConfirmOrder() {
            var file = $('#uploadFiletxxt')[0];
            var data = GetConfirmMedicine();

            //var data = JSON.stringify({ 'model': model });
            $.ajax({
                type: 'POST',
                url: baseUrl + 'Home/PostPharmcyData',
                data: { imagePath: file, model: data },
                //contentType: 'application/json; charset=utf-8',
                //dataType: 'json',
                //contentType: false,
                //processData: false,
                success: function (response) {

                }
            })
        }

     [HttpPost]
     public ActionResult PostPharmcyData(HttpPostedFileBase[] imagePath, PharmacyViewModel model)
     }

【问题讨论】:

    标签: jquery ajax asp.net-mvc


    【解决方案1】:

    Upload files using AJAX in ASP.Net MVC

    在您的控制器中,您可以使用 Request 对象来保存文件。

    【讨论】:

    • PharmacyProductList 将如何显示?在控制器 VeiwModel [HttpPost] public ActionResult PostPharmcyData(HttpPostedFileBase[] imagePath, PharmacyViewModel model) }
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多