C# fileUpload视频上传

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


"true" targetFramework="4.5" />

"4.5" maxRequestLength="1073741824" executionTimeout="3600" />




"1073741824"/> 
 
 

index页面

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

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


"en">
"UTF-8">jQuery File Upload Demo"stylesheet" href="~/JS/bootstrap/css/bootstrap.min.css">"stylesheet" href="~/CSS/fileupload.css">

class="container">

jQuery File Upload Demo


class="row fileupload-buttonbar">class="col-lg-12">class="btn btn-success fileinput-button">class="glyphicon glyphicon-plus">Add files..."file" id="fileupload" name="files" multiple>"checkbox" class="toggle">class="container"> class="row" id="imglist">"preview" src="" width="60" height="60" />class="progress">class="progress-bar" style="width: 0%;">
 

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(1970, 1, 1));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;}}

 

转载于:https://www.cnblogs.com/lcidy/p/10196310.html


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部