首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏编程进阶实战

    .Net之使用Jquery Ajax通过FormData对象异步提交图片文件到服务端保存并返回保存的图片路径

    <returns></returns> 8 [HttpPost] 9 public ActionResult FileLoad(FormContext context) 10 { 11 HttpPostedFileBase httpPostedFileBase = Request.Files[0];//获取二进制图片文件流 12 if (httpPostedFileBase ! ControllerContext.HttpContext.Response.Charset = "UTF-8"; 18 19 string fileName = Path.GetFileName(httpPostedFileBase.FileName string fileExtension = Path.GetExtension(fileName);//文件扩展名 21 22 byte[] fileData = ReadFileBytes(httpPostedFileBase / <param name="fileData">图片文件流</param> 48 /// <returns></returns> 49 private byte[] ReadFileBytes(HttpPostedFileBase

    3K20发布于 2019-08-28
  • 来自专栏大内老A

    ASP.NET MVC以ValueProvider为核心的值提供系统: DictionaryValueProvider

    从下面的代码片断所示,该属性类型为HttpFileCollectionBase,是一个元素类型为HttpPostedFileBase的集合。 this[int index] { get; } 10: public virtual HttpPostedFileBase this[string name] { get; } 11 数组,这是因为在同一个表单中可以定义多个同名的文件输入元素,所以在以文件元素名称作为Key的字典中,字典元素的值自然就是一个HttpPostedFileBase的列表。 > foo = (IEnumerable<HttpPostedFileBase>)valueProvider.GetValue("foo").ConvertTo(typeof(IEnumerable<HttpPostedFileBase >)); 12: IEnumerable<HttpPostedFileBase> bar = (IEnumerable<HttpPostedFileBase>)valueProvider.GetValue

    2.5K80发布于 2018-01-15
  • 来自专栏编程进阶实战

    .Net之Layui多图片上传

    窗体中输入的数据进行封装</param> /// <returns></returns> [HttpPost] public ActionResult FileLoad(FormContext context) { HttpPostedFileBase httpPostedFileBase = Request.Files[0];//获取二进制图片文件流 if (httpPostedFileBase ! -8"); ControllerContext.HttpContext.Response.Charset = "UTF-8"; string fileName = Path.GetFileName(httpPostedFileBase.FileName /原始文件名称 string fileExtension = Path.GetExtension(fileName);//文件扩展名 byte[] fileData = ReadFileBytes(httpPostedFileBase summary> /// <param name="fileData">图片文件流</param> /// <returns></returns> private byte[] ReadFileBytes(HttpPostedFileBase

    1.6K40发布于 2019-08-28
  • 来自专栏编程进阶实战

    ASP.NET MVC+LayUI视频上传

    ActionResult FileLoad(FormContext context)//FemContext对验证和处理html窗体中输入的数据进行封装 { HttpPostedFileBase httpPostedFileBase = Request.Files[0];//获取文件流 if (httpPostedFileBase ! ControllerContext.HttpContext.Response.Charset = "UTF-8"; string fileName = Path.GetFileName(httpPostedFileBase.FileName fileExtension = Path.GetExtension(fileName);//文件扩展名 byte[] fileData = ReadFileBytes(httpPostedFileBase name="fileData">图片文件流</param> /// <returns></returns> private byte[] ReadFileBytes(HttpPostedFileBase

    3.5K20发布于 2020-08-11
  • 来自专栏全栈程序员必看

    asp.net MVC简单图片上传

    HttpPost] public ActionResult UploadImg() { //接收表单传递过来的图片 HttpPostedFileBase ActionResult UploadImg() //{ // if (Request.Files.Count > 0) // { // HttpPostedFileBase

    5K20编辑于 2022-09-15
  • 来自专栏CSDNToQQCode

    ajax图片上传

    } }); } </script> 后台代码(这里是.NET语言测试的): public ActionResult UploadPic(HttpPostedFileBase

    4.8K40编辑于 2022-11-29
  • 来自专栏逸鹏说道

    上传伪技术~很多人都以为判断了后缀,判断了ContentType,判断了头文件就真的安全了。是吗?

    /// <param name="file"></param> /// <returns></returns> public JsonResult UploadA(HttpPostedFileBase /// <param name="file"></param> /// <returns></returns> public JsonResult UploadB(HttpPostedFileBase 的时候有应该有一定的验证[我把含有一句话木马的图片上传,最后会返回一张空图片]) /// /// <returns></returns> public JsonResult UploadC(HttpPostedFileBase

    1.5K80发布于 2018-04-10
  • 来自专栏葡萄城控件技术团队

    MVC5:使用Ajax和HTML5实现文件上传功能

    在upload 方法中,可以从HttpPostedfileBase对象中获取文件信息,该对象包含上传的文件的基本信息如Filename属性,Contenttype属性,inputStream属性等内容, 1: [HttpPost] 2:   3: public JsonResult Upload(HttpPostedFileBase uploadedFile) 4 here 12: } 接下来添加服务器端处理代码,与上文添加的代码类似,需要做的就是接受一系列的文件列表,如下: 1: public JsonResult UplodMultiple(HttpPostedFileBase [] uploadedFiles) 确保 HttpPostedFileBase 数组名称与append 方法中的名称相同,只有这样,MVC才能映射到文件数组中。 1: public JsonResult UplodMultiple(HttpPostedFileBase[] uploadedFiles) 2: dataString.append("uploadedFiles

    4.9K101发布于 2018-01-10
  • 来自专栏葡萄城控件技术团队

    七天学会ASP.NET MVC (六)——线程问题、异常处理、自定义URL

    fileUpload {get; set ;} 4: } HttpPostedFileBase 将通过客户端提供上传文件的访问入口。 什么是 HttpPostedFileBaseHttpPostedFileBase将通过客户端提供文件上传的访问入口,Model Binder 会在Post请求期间更新 FileUploadViewModel类中的所有属性值。 创建多文件输入控件,每个控件有唯一的名称,FileUploadViewModel类会为每个控件创建 HttpPostedFileBase类型的属性,每个属性名称应该与控件名称匹配。 2. 创建多文件输入控件,每个控件有相同的名称,创建类型的List列表,代替创建多个HttpPostedFileBase类型的属性。

    4.9K100发布于 2018-01-10
  • 来自专栏CSDNToQQCode

    ASP.NET MVC (三、表单与文件上传)

    目录 前言: 1、 表单操作 2、文件上传 前言: 本章节主要针对文件上传进行强化练习,关键字【HttpPostedFileBase files,enctype="multipart/form-data "userName"></param> /// <param name="files"></param> [HttpPost] public void AddInfo(string userName,HttpPostedFileBase

    3.4K30编辑于 2022-11-29
  • 来自专栏CSDNToQQCode

    .NET MVC第四章、模型绑定获取表单数据

    文件获取,必须使用post接收 控制器 [HttpPost] public ActionResult GetImg(HttpPostedFileBase file) { string fileName @ViewBag.userName
    @ViewBag.age 未传参效果: 传参效果 文件上传 控制器 [HttpPost] public ActionResult GetImg(HttpPostedFileBase

    1.6K20编辑于 2022-11-30
  • 来自专栏编程进阶实战

    .Net使用HttpClient以multipart/form-data形式post上传文件及其相关参数

    后端接收图片和参数,并将图片文件流转化为图片字节类型数据: //接收前端图片文件信息 [HttpPost] public JsonResult ImageUpload(FormContext context) { HttpPostedFileBase summary> /// <param name="fileData">文件流数据</param> /// <returns></returns> private byte[] ReadFileBytes(HttpPostedFileBase

    3.8K20发布于 2019-09-10
  • 来自专栏CSDNToQQCode

    ASP.NET MVC上传图片前后台内容

    files"></param> /// <returns></returns> [HttpPost] public ActionResult SaveInfo(HttpPostedFileBase

    3.5K20编辑于 2022-11-28
  • 来自专栏全栈程序员必看

    ASP.NET MVC 上传文件方法

    图中代码有用到 HttpPostedFileBase 是一个类,作用就是提供对客户端已上载的单独的文件的访问。

    5K10编辑于 2022-09-15
  • 来自专栏逸鹏说道

    07.LoT.UI 前后台通用框架分解系列之——轻巧的文本编辑器

    /// 图片上传 /// /// <returns></returns> public ContentResult Upload(HttpPostedFileBase

    81670发布于 2018-04-10
  • 来自专栏晓晨的专栏

    asp.net mvc 实现上传文件带进度条

    } } ); 后端接收文件上传请求的action: 1 [HttpPost] 2 public ActionResult UploadImage(HttpPostedFileBase

    4.3K31发布于 2018-06-22
  • 来自专栏阿炬.NET

    【要什么自行车】ASP.NET MVC4笔记02:上传文件 uploadify 组件使用

    www.yxweb.com.cn/images/upphoto.gif" alt="请上传工作照" /> 3、Controller public ActionResult Upload(HttpPostedFileBase

    78350发布于 2018-05-11
  • 来自专栏await

    layui的文件上传跟文件保存

    所以使用JSON数据返回 string res=string.Empty; //获取文件 try { HttpPostedFileBase

    3.1K10发布于 2021-11-17
  • 来自专栏一个爱瞎折腾的程序猿

    C#使用NOPI导入Excel

    sheetName">表名,默认取第一张</param> /// <returns></returns> public static DataTable Import(System.Web.HttpPostedFileBase

    1.6K20发布于 2018-09-14
  • 来自专栏一个爱瞎折腾的程序猿

    asp.net mvc项目实记-开启伪静态-Bundle压缩css,js

    def; } [HttpPost] public ActionResult Upload(HttpPostedFileBase file) { if (

    1.5K30发布于 2019-02-25
领券