要实现大文件上传必须配置webConfig例如:

<system.web>
<compilation debug="true" targetFramework="4.5" />
<!--<httpRuntime targetFramework="4.5" />-->
<httpRuntime targetFramework="4.5" maxRequestLength="" executionTimeout="" />
</system.web> <system.webServer>
<security>
<requestFiltering>
<!--修改服务器允许最大长度-->
<requestLimits maxAllowedContentLength=""/>
</requestFiltering>
</security>
</system.webServer>

index页面

运用jQuery-file-Upload需要引用以下js

jquery.ui.widget.js
jquery.iframe-transport.js
jquery.fileupload.js

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jQuery File Upload Demo</title>
<link rel="stylesheet" href="~/JS/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="~/CSS/fileupload.css">
<script src="~/JS/jQuery.js"></script>
<style>
img {
max-width:50px;
overflow:hidden;
margin:30px;
}
li {
list-style:none;
}
.progress {
width: 350px;
margin-left: 76px;
margin-top: -90px;
display:none;
}
</style>
</head>
<body>
<div class="container">
<h1>jQuery File Upload Demo</h1>
<br>
<div class="row fileupload-buttonbar">
<div class="col-lg-12">
<!-- The fileinput-button span is used to style the file input field as button -->
<span class="btn btn-success fileinput-button">
<i class="glyphicon glyphicon-plus"></i>
<span>Add files...</span>
<input type="file" id="fileupload" name="files" multiple>
</span>
<button type="submit" class="btn btn-primary start">
<i class="glyphicon glyphicon-upload"></i>
<span id="Start">Start upload</span>
</button>
<button type="reset" class="btn btn-warning cancel">
<i class="glyphicon glyphicon-ban-circle"></i>
<span id="Cancle">Cancel upload</span>
</button>
<button type="button" class="btn btn-danger delete">
<i class="glyphicon glyphicon-trash"></i>
<span id="Delete">Delete</span>
</button>
<input type="checkbox" class="toggle"> <div class="container">
<div class="row" id="imglist">
<img id="preview" src="" width="" height="" />
</div>
<div class="progress">
<div class="progress-bar" style="width: 0%;">
</div>
</div>
</div> </div>
</div>
</div>
</body>
 <script type="text/javascript">
$('#fileupload').fileupload({
url: "/Home/img",
Type: "POST",
dataType: 'json',
autoUpload: true,
acceptFileTypes: "/(\.|\/)(gif|jpe?g|png|xlsx|mp4)$/i",
add: function (e, data)
{
$("#Start").click(function () {
data.submit();
})
},
success:function(response, status)
{
var obj = JSON.parse(response);
var imgPath = obj["filePath"];
$("#imglist").append('<li><img src="' + imgPath + '" /> </li>'); },
done: function (e, data) {
alert("upload finish");
},
error: function (error) {
alert("error");
},
progressall: function (e, data) { //进度条显示
var progress = parseInt(data.loaded / data.total * , );
$('.progress .progress-bar').css(
'width',
progress + '%'
);
$('.progress-bar').html(
progress + '%'
);
$('.progress ').css(
'display',
'block'
);
}
});
</script>

Controller

public JsonResult img(HttpPostedFileBase files)//, string deviceCode, string type
{
try
{
string localPath = "/uploads/images/" + DateTime.Now.ToString("yyyyMMdd");
string path = Server.MapPath("~" + localPath);
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
TimeSpan ts = DateTime.Now - TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(, , ));
string fileName = (long)ts.TotalMilliseconds + Path.GetExtension(files.FileName);
files.SaveAs(path + "/" + fileName);
return Json("{\"filePath\":\"" + localPath + "/" + fileName + "\",\"sourePath\":\"" + files.FileName + "\"}"); }
catch (Exception ex)
{
return null;
}
}

C# fileUpload视频上传的更多相关文章

  1. ASP.NET MVC+LayUI视频上传

    前言: 前段时间在使用APS.NET MVC+LayUI做视频上传功能的时,发现当上传一些内存比较大的视频就会提示上传失败,后来通过查阅相关资料发现.NET MVC框架为考虑安全问题,在运行时对请求的 ...

  2. 对FileUpload文件上传控件的一些使用方法说明

    //创建时间:2014-03-12 //创建人:幽林孤狼 //说明:FileUpload文件上传控件使用说明(只是部分)已共享学习为主 //可以上传图片,txt文档.doc,wps,还有音频文件,视屏 ...

  3. ASP.NET中扩展FileUpload的上传文件的容量

    ASP.NET中扩展FileUpload只能上传小的文件,大小在4MB以内的.如果是上传大一点的图片类的可以在web.config里面扩展一下大小,代码如下 <system.web> &l ...

  4. bootstrap-fileinput视频上传

    在页面编写一个input框: <input id="input-repl-3a" name="videoFileAddress" type="f ...

  5. 【腾讯云的1001种玩法】 Laravel 整合微视频上传管理能力,轻松打造视频App后台

    版权声明:本文由白宦成原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/108597001488193402 来源:腾云阁 h ...

  6. 微信小程序选择视频,视频上传,视频播放

    请查看链接地址看具体详情: 选择视频: https://mp.weixin.qq.com/debug/wxadoc/dev/api/media-video.html#wxchoosevideoobje ...

  7. (转)ASP.NET(C#)FileUpload实现上传限定类型和大小的文件到服务器

    上传文件有两个主要的目的地,一个是服务器,另一个是数据库,ASP.NET内置了FileUpload这个上传控件,文本框显示用户选择的文件的全名. 其属性主要包括: ContenLength:上传文件大 ...

  8. 腾讯云点播视频存储(Web端视频上传)

    官方文档 前言 所谓视频上传,是指开发者或其用户将视频文件上传到点播的视频存储中,以便进行视频处理.分发等. 一.简介 腾讯云点播支持如下几种视频上传方式: 控制台上传:在点播控制台上进行操作,将本地 ...

  9. 「小程序JAVA实战」小程序视频上传方法的抽象复用(57)

    转自:https://idig8.com/2018/09/23/xiaochengxujavashizhanxiaochengxushipinshangchuanfangfadechouxiangfu ...

随机推荐

  1. 利用gotty在web浏览器模拟终端登录

    1.随机url,9000端口访问 gotty -p " -r -w bash -i 2.简单用户名密码授权,9090端口访问 gotty -p -c user:password -w bas ...

  2. css中“~”和“>”是什么意思

    p~ul选择器 p之后出现的所有ul. 两种元素必须拥有相同的父元素,但是 ul不必直接紧随 p. css中“>”是: css3特有的选择器,A>B 表示选择A元素的所有子B元素. 与A ...

  3. 05_python_字典

    一.字典定义 字典是python中唯一的映射类型,以{ }括起来的键值对组成,在dict中key是唯一的.在保存时,根据key来计算一个内存地址,然后把key-value保存至地址中.这种算法是has ...

  4. ajax post 请求发送 json 字符串

    $.ajax({ // 请求方式 type:"post", // contentType contentType:"application/json", // ...

  5. 线性表java实现

    顺序表 public class SequenceList { /* * content,节点内容 * location,节点在表中的位置(序号) * */ private String conten ...

  6. EXECUTE 后的事务计数指示缺少了 COMMIT 或 ROLLBACK TRANSACTION 语句。上一计数 = 1,当前计数 = 2

    理解这一句话: 一个begin tran会增加一个事务计数器,要有相同数量的commit与之对应,而rollback可以回滚全部计数器 这个错误一般是出现在嵌套事务中. 测试环境 sql 2008 例 ...

  7. C#编程任务: 把工作交给别人并等待其执行完成

    生活中有这样的场景: 我有一件事情需要别人帮忙去办, 但是别人也很忙呀, 所以我只能把任务记载他的任务清单上, 等他一个个扫下来扫到我的并且完成之后再来告诉我. 这其实是一个多线程的问题. 我是线程A ...

  8. 课程一(Neural Networks and Deep Learning),第三周(Shallow neural networks)—— 0、学习目标

    Learn to build a neural network with one hidden layer, using forward propagation and backpropagation ...

  9. Spark集群测试

    1. Spark Shell测试 Spark Shell是一个特别适合快速开发Spark原型程序的工具,可以帮助我们熟悉Scala语言.即使你对Scala不熟悉,仍然可以使用这一工具.Spark Sh ...

  10. C++与C的联系与区别

    C++与C的联系: C++是在C语言的基础上开发的一种面向对象编程语言,应用广泛.C++支持多种编程范式 --面向对象编程.泛型编程和过程化编程. 其编程领域众广,常用于系统开发,引擎开发等应用领域, ...