form表单一次上传多种类型的图片(每种类型的图片可以上传多张)

controller中的action方法

public ActionResult UploadImage( )
        {

     int imageType=(int)Request.Form["ImageType"];

     //整体图片集合
            IList<HttpPostedFileBase> wholePictureIList = Request.Files.GetMultiple("WholePicture");//HttpPostedFileBase:充当类的基类,这些类提供对客户端上传的文件的单独访问;Request.Files.GetMultiple(string name):返回与name匹配的所有文件

     //周边图片集合
            IList<HttpPostedFileBase> AroundSupportPictureIList = Request.Files.GetMultiple("AroundSupportPicture");

if (wholePictureIList[0].FileName != "")
            {
                foreach (var item in wholePictureIList)
                {
                    byte[] b = new byte[item.ContentLength];
                    item.InputStream.Read(b, 0, item.ContentLength);
                    model.WholePicture.Add(b);//model.WholePicture是byte[]的集合,即图片的流文件,可以存到数据库中
                }
            }
            if (AroundSupportPictureIList[0].FileName != "")
            {
                foreach (var item in AroundSupportPictureIList)
                {
                    byte[] b = new byte[item.ContentLength];
                    item.InputStream.Read(b, 0, item.ContentLength);
                    model.AroundSupportPicture.Add(b);
                }
            }
            int userId = (int)Session["UserId"];
            ManageParkPediaService service = new ManageParkPediaService();
           StateInfo<int> infoT = service.SaveImage(model, userId);
           return Json(infoT);
        }

view中的代码

引入<script src="~/Scripts/jquery.form.js"></script>

<script type="text/javascript">
        //上传图片
        function uploadImage() {

            console.log(222);
            $('#fileForm').ajaxSubmit({
                success: function (msg) {
                    console.log(msg);
                }

            });
        }
</script>

<form id="fileForm" method="post" action="http://localhost:38594/UploadImage/SaveImageResult" enctype="multipart/form-data">

    <input type="text" name="ImageType" id="ImageType" value="1" />
            <input type="file" name="WholePicture" id="WholePicture" readonly multiple />

    <input type="file" name="AroundSupportPicture" id="AroundSupportPicture" readonly multiple />
            <input type="button" onclick="uploadImage()" value="上传图片" />
        </form>

MVC下form表单一次上传多种类型的图片(每种类型的图片可以上传多张)的更多相关文章

  1. MVC中Form表单的提交

    概述 Web页面进行Form表单提交是数据提交的一种,在MVC中Form表单提交到服务器.服务端接受Form表单的方式有多种,如果一个Form有2个submit按钮,那后台如何判断是哪个按钮提交的数据 ...

  2. 今天在研究jquery用ajax提交form表单中得数据时,学习到了一种新的提交方式

    今天在研究jquery用ajax提交form表单中得数据时,学习到了一种新的提交方式 jquery中的serialize() 方法 该方法通过序列化表单值,创建 URL 编码文本字符串 序列化的值可在 ...

  3. Ajax模拟Form表单提交,含多种数据上传

    ---恢复内容开始--- Ajax提交表单.使用FormData提交表单数据和上传的文件(这里的后台使用C#获取,你可以使用Java一样获取) 有时候前台的数据提交到后台,不想使用form表单上传,希 ...

  4. 关于Form表单一些基础知识

    1.两个重要属性: action:表单需要提交的服务器地址 method:表单提交数据使用的方法,get/post >>>get和post的区别 ①get传参使用URL传递,所有参数 ...

  5. ASP.NET MVC 与Form表单交互

    一,Form包含文件类(单选文件) <form id="ImgForm" method="POST" enctype="multipart/fo ...

  6. Request.getparameternames 获取form表单里面所有的请求参数 。 返回一个Enumeration类型的枚举.

    通过Enumeration的hasMoreElements()方法遍历.再由nextElement()方法获得枚举的值.此时的值是form表单中所有控件的name属性的值. 最后通过request.g ...

  7. flask通过form表单一次上传多个文件

    基本上,用了flask官网的示例代码(中文版,英文版),稍微做了修改. import os from flask import Flask, flash, request, redirect, url ...

  8. layui中进行form表单一些问题

    最近一段时间一直在用layui来写一些前段页面,发现有几个问题,不知道是我的编译器的问题还是什么,总之目前是自己改成功了,在这里分享下. 第一个是用layui去写单选按钮,网页上不会显示出来.解决方法 ...

  9. mvc中form表单提交的几种形式

    第一种方式:submit 按钮 提交 <form action="MyDemand" method="post"> <span>关键字: ...

随机推荐

  1. CTabCtrl

    转载至 http://blog.csdn.net/jacklam200/archive/2008/08/01/2753797.aspx 一.在对话框视图中加入CTabCtrl控件 资源ID:IDC_T ...

  2. Task Cancellation: Parallel Programming

    http://beyondrelational.com/modules/2/blogs/79/posts/11524/task-cancellation-parallel-programming-ii ...

  3. jdk8 eclipse luna market crashed

    THAT WORKS! Eclipse Luna starts normally when I first do the suggested: export SWT_GTK3=0 https://bu ...

  4. 第四弹:overfeat

    overfeat是在AlexNet出现后,推出来的模型,其不仅用于物体分类,来用于定位,检测等,可以说是一个涉及很多应用场景的通用模型,值得看看. 本文将从两个方面来讲解,第一部分从论文角度来说一说, ...

  5. hbase 第一篇

    参考:http://www.jdon.com/38244 http://chuanwang66.iteye.com/blog/1683533

  6. [转]hibernate缓存机制所有详解

    以下文章来自http://www.blogjava.net/tbwshc/articles/380013.html Hibernate 所有缓存机制详解 hibernate提供的一级缓存 hibern ...

  7. JUnit----单元测试

    为什么进行单元测试? 1. 重用测试, 应付将来实现的变化. 2. 明确指定我的东西是没问题的. Failure, error的区别? Failure只测试失败, Error指程序本身出错 1. ne ...

  8. 照着例子学习 protobuf-lua

    参考文章:cocos2dx使用lua和protobuf 首先得下载protobuf-gen-lua的插件,插件Git地址在此. 下载完之后进入到protoc-gen-lua\plugin这个目录,并在 ...

  9. 通过 File API 使用 JavaScript 读取文件

    原文地址:http://www.html5rocks.com/zh/tutorials/file/dndfiles/ 简介 HTML5 终于为我们提供了一种通过 File API 规范与本地文件交互的 ...

  10. 解决在某些IE浏览器下字符乱码的问题

    习惯上我们写字符声明都是 <meta charset="utf-8"> 在绝大多数浏览器都没有问题,但是在操蛋的IE上有时候会出现编码错误!! 解决方案: <me ...