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. HDU 5172 GTY's gay friends 线段树

    GTY's gay friends Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  2. 利用fiddler给android模拟器抓包

    启动模拟器 setting---wireless&networks----mobile networks----access pointnames -------------------- 然 ...

  3. MC34063+MOSFET扩流 12V-5V 折腾出了高效率电路(转)

    源:http://www.amobbs.com/thread-5484710-1-1.html 从网上找到一些MC34063扩流降压电路图,一个个的试,根本达不到我的基本要求,全都延续了34063的降 ...

  4. Persistent Bookcase

    Persistent Bookcase time limit per test 2 seconds memory limit per test 512 megabytes input standard ...

  5. web项目编译出错时,原因之一,可能是build path 中order and Export引起

    build path中的order and Export,如果两个libarary中有相同功能的jar包,则编译器会选择顺序在前的jar包中相应的类作为编译所需. 所以,当项目jar包较多的时候,如果 ...

  6. NSMutableDictionary

    NSDictionary *dic = @{@"name":@"yj", @"age":@"24", @"ho ...

  7. 方法的标签_With携带

    方法中参数的标签: 标签的由来:1.标签也是方法名的一部分:2.为了提高程序的阅读性:OC方法允许我们给每个参数添加一个标签来说明当前参数的含义: 标签的作用:标签是为了标识变量的,因此标签名和变量名 ...

  8. [Unity]SQLite-C#调用

    SQLite数据库-Unity操作 项目开发的时候,经常会遇到的一种需求,数据存储 离线缓存的数据类型很多,大致分成两类 字符串文本数据 多媒体数据 字符串数据的类型只有字符串,但是结构有很多: xm ...

  9. HMM 隐马尔科夫模型

    参考如下博客: http://www.52nlp.cn/itenyh%E7%89%88-%E7%94%A8hmm%E5%81%9A%E4%B8%AD%E6%96%87%E5%88%86%E8%AF%8 ...

  10. POJ 3421 X-factor Chains

    线型素数筛+质因素分解+组合数. AC后发现这样做效率有点低..766ms. #include<stdio.h> #include<string.h> #include< ...