要实现大文件上传必须配置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. Visual Studio Code 显示隐藏的.git文件和目录

    在默认设置中,Visual Studio Code 将下列文件文件排除在显示列表中: "files.exclude": { "**/.git": true, & ...

  2. fetch更新本地仓库两种方式:

    来源:https://www.cnblogs.com/chenlogin/p/6592228.html //方法一 $ git fetch origin master //从远程的origin仓库的m ...

  3. dubbo实现原理之动态编译

    Dubbo为了实现基于spi思想的扩展特性,特别是能够灵活添加额外功能,对于扩展或则策略选择的设配类能够动态生成.对于一些需求已知的类如Protocal,它们的设配类代码dubbo可以直接的提供,但是 ...

  4. [vuejs] 终端npm run dev 不能自动打开浏览器运行项目解决办法

    终端执行: npm run dev 出现: I Your application is running here: http://localhost:8080 但并没有打开浏览器运行项目 解决办法: ...

  5. lnmp平台搭设

    软件链接:https://pan.baidu.com/s/14gAZ67iXWhEdzvEXMiGfVg             提取码:ai1s 只是在一台服务器上搭设,为centos7.2环境 安 ...

  6. Python中Flask框架SQLALCHEMY_ECHO设置

    在用配置类的方式给app设置配置时, SQLALCHEMY_ECHO 这个是记录打印SQL语句用于调试的, 一般设置为False, 不然会在控制台输出一大堆的东西 /home/python/.virt ...

  7. Python小白学习之路(二十四)—【装饰器】

    装饰器 一.装饰器的本质 装饰器的本质就是函数,功能就是为其他函数添加附加功能. 利用装饰器给其他函数添加附加功能时的原则: 1.不能修改被修饰函数的源代码        2.不能修改被修饰函数的调用 ...

  8. webgl之绘图要点

    3D世界是由点组成的,两个点组成一条直线,而三个点就可以组成一个三角形,通过三角形就可以组成任意形状的物体,而这种组成的物体我们称为Mesh模型,接着Mesh模型加上纹理就组成了真实的3D世界.下面我 ...

  9. [Fatal Error] :3:13: Open quote is expected for attribute "{1}" associated with an element type "id".

    用DOM解析XML时出现了如下错误: [Fatal Error] :3:13: Open quote is expected for attribute "{1}" associa ...

  10. Intellij IDEA 环境配置与使用

    Intellij IDEA 是我感觉最牛X的IDE开发工具,没有之一! 先share一篇教程: http://pan.baidu.com/s/1i3fzJff 调整字体 设置默认的JDK 显示行号 版 ...