C# fileUpload视频上传
要实现大文件上传必须配置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视频上传的更多相关文章
- ASP.NET MVC+LayUI视频上传
前言: 前段时间在使用APS.NET MVC+LayUI做视频上传功能的时,发现当上传一些内存比较大的视频就会提示上传失败,后来通过查阅相关资料发现.NET MVC框架为考虑安全问题,在运行时对请求的 ...
- 对FileUpload文件上传控件的一些使用方法说明
//创建时间:2014-03-12 //创建人:幽林孤狼 //说明:FileUpload文件上传控件使用说明(只是部分)已共享学习为主 //可以上传图片,txt文档.doc,wps,还有音频文件,视屏 ...
- ASP.NET中扩展FileUpload的上传文件的容量
ASP.NET中扩展FileUpload只能上传小的文件,大小在4MB以内的.如果是上传大一点的图片类的可以在web.config里面扩展一下大小,代码如下 <system.web> &l ...
- bootstrap-fileinput视频上传
在页面编写一个input框: <input id="input-repl-3a" name="videoFileAddress" type="f ...
- 【腾讯云的1001种玩法】 Laravel 整合微视频上传管理能力,轻松打造视频App后台
版权声明:本文由白宦成原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/108597001488193402 来源:腾云阁 h ...
- 微信小程序选择视频,视频上传,视频播放
请查看链接地址看具体详情: 选择视频: https://mp.weixin.qq.com/debug/wxadoc/dev/api/media-video.html#wxchoosevideoobje ...
- (转)ASP.NET(C#)FileUpload实现上传限定类型和大小的文件到服务器
上传文件有两个主要的目的地,一个是服务器,另一个是数据库,ASP.NET内置了FileUpload这个上传控件,文本框显示用户选择的文件的全名. 其属性主要包括: ContenLength:上传文件大 ...
- 腾讯云点播视频存储(Web端视频上传)
官方文档 前言 所谓视频上传,是指开发者或其用户将视频文件上传到点播的视频存储中,以便进行视频处理.分发等. 一.简介 腾讯云点播支持如下几种视频上传方式: 控制台上传:在点播控制台上进行操作,将本地 ...
- 「小程序JAVA实战」小程序视频上传方法的抽象复用(57)
转自:https://idig8.com/2018/09/23/xiaochengxujavashizhanxiaochengxushipinshangchuanfangfadechouxiangfu ...
随机推荐
- LogisticRegression in MLLib (PySpark + numpy+matplotlib可视化)
参考'LogisticRegression in MLLib' (http://www.cnblogs.com/luweiseu/p/7809521.html) 通过pySpark MLlib训练lo ...
- spark-mllib 密集向量和稀疏向量
spark-mllib 密集向量和稀疏向量 MLlib支持局部向量和矩阵存储在单台服务器,也支持存储于一个或者多个rdd的分布式矩阵 . 局部向量和局部矩阵是用作公共接口的最简单的数据模型. 基本的线 ...
- ASP.NET SignalR Troubeshooting
method could not be resolved 场景: Javascript客户端不生成代理,调用服务端方法. 按照官网文档的用法: contosoChatHubProxy.invoke(' ...
- 通过JS拦截 pushState 和 replaceState 事件
history.pushState 和 history.replaceState 可以在不刷新当前页面的情况下更改URL,但是这样就无法获取通过AJAX得到的新页面的内容了.虽然各种HTML5文档说 ...
- ASP .Net C# ---CSV导入导出
CSV和Excel大致相同 复制下来 数据传到方法里面就可以了 /// <summary> /// DataTable数据写入CSV文件 /// </summary> /// ...
- c#中的几种Dialog
1.OpenFileDialog private void FileOpen_Click(object sender, EventArgs e) { OpenFileDialog openFile = ...
- 【BZOJ1052】 [HAOI2007]覆盖问题
BZOJ1052 [HAOI2007]覆盖问题 前言 小清新思维题. 最近肯定需要一些思维题挽救我这种碰到题目只会模板的菜鸡. 这题腾空出世? Solution 考虑一下我们二分答案怎么做? 首先转换 ...
- 3、JUC--ConcurrentHashMap 锁分段机制
ConcurrentHashMap Java 5.0 在 java.util.concurrent 包中提供了多种并发容器类来改进同步容器的性能. ConcurrentHashMap 同步容器 ...
- C#6.0语言规范(十七) 特性
许多C#语言使程序员能够指定有关程序中定义的实体的声明性信息.例如,在一个类中的方法的可访问性由与装饰它指定method_modifier小号public,protected,internal,和pr ...
- 安装MySQL-python时报错
(py27) [root@test SimpletourDevops]# pip install MySQL-python DEPRECATION: Python 2.7 will reach the ...