uploadify多文件上传实例--C#
下载uploadify文件
http://www.uploadify.com/
HTML(视图)
<html lang="zh-cn">
<head>
<meta content="true">
<meta charset="UTF-8">
<script src="~/Areas/Test/Uploadify/jquery.uploadify.js"></script>
<link href="~/Areas/Test/Uploadify/uploadify.css" rel="stylesheet" />
<title>uploadify多文件上传例子</title>
</head>
<body>
<input type="file" id="file_upload" name="file_upload" />
</body>
</html>
JS
<script>
$(function () {
$('#file_upload').uploadify({
'swf': '@Url.Content("/Areas/Test/Uploadify/uploadify-v3.1/uploadify.swf")',
'uploader': '@Url.Action("UploadAppraisal")?resultPath=Upload',
'auto': true,
'fileTypeExts': '*.*',
'fileTypeDesc':'All Files',
'fileSizeLimit': '',
'buttonText': '添加文件',
'width': ,
'height': ,
'margin-right': ,
multi: false,
queueSizeLimit: ,
timeoutuploadLimit: ,
removeCompleted: true,
uploadLimit: ,
'onSelect': function (file) { },
'onUploadStart' : function(file) { },
'onUploadProgress': function (file, bytesUploaded, bytesTotal, totalBytesUploaded, totalBytesTotal) { },
'onInit': function () { },
'onUploadSuccess': function (file, data, response) { }
});
});</script>
后台(MVC控制器)
public JsonResult UploadAppraisal(HttpPostedFileBase fileData, string resultPath)
{
if (fileData != null)
{
try
{
// 文件上传后的保存路径
string filePath = Server.MapPath("../Upload/temp");
string Size = HumanReadableFilesize(fileData.ContentLength);
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
} string fileNames = Path.GetFileName(fileData.FileName);// 原始文件名称
string fileName = Regex.Match(fileNames, @".*?(?=[.])").Value;//去掉后缀名字的文件名字
string fileExtension = Path.GetExtension(fileNames); // 文件扩展名
string saveName = Guid.NewGuid().ToString() + fileExtension; // 保存文件名称
string path = filePath + "\\" + saveName;
string Filesize = HumanReadableFilesize(fileData.ContentLength);//字节大小
string FileDw = HumanReadableFile(fileData.ContentLength);//字节单位
fileData.SaveAs(path); return Json(new
{ Success = true, FileName = saveName});
}
catch (Exception ex)
{
return Json(new
{ Success = false, Message = ex.Message }, JsonRequestBehavior.AllowGet);
}
}
else
{
return Json(new
{ Success = false, Message = "请选择要上传的文件!" }, JsonRequestBehavior.AllowGet);
}
}
一个页面有多个上传控件
修改jquery.uploadify.js、jquery.uploadify.min.js
var mydate = new Date();
this.movieName = "SWFUpload_" + mydate.getTime().toString();
上传大文件(Web.config)
Web.config添加一下代码
<system.web>
<compilation debug="true" targetFramework="4.5" />
<!--maxRequestLength就是文件的最大字符数,最大值不能超过2个G左右,executionTimeout是超时时间-->
<httpRuntime targetFramework="4.5" maxRequestLength="" executionTimeout="" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<!--修改服务器允许最大长度-->
<requestLimits maxAllowedContentLength=""/>
</requestFiltering>
</security>
</system.webServer>
uploadify多文件上传实例--C#的更多相关文章
- Jquery Uploadify多文件上传实例
jQuery Uploadify开发使用的语言是java. 详细的相关文档,可以参考官网的doc:http://www.uploadify.com/documentation/ 官网的讲解还是很详细的 ...
- PHP中,文件上传实例
PHP中,文件上传一般是通过move_uploaded_file()来实现的. bool move_uploaded_file ( string filename, string destinati ...
- uploadify多图片上传实例
upload.php <html> <head> <meta http-equiv="Content-Type" content="text ...
- PHP学习笔记--文件目录操作(文件上传实例)
文件操作是每个语言必须有的,不仅仅局限于PHP,这里我们就仅用PHP进行讲解 php的文件高级操作和文件上传实例我放在文章的最后部分.--以后我还会给大家写一个PHP类似于网盘操作的例子 注意:阅读此 ...
- ExtJS:文件上传实例
ExtJS:文件上传实例 var ext_dateFormat = 'Y-m-d H:i:s'; var dateFormat = 'yyyy-MM-dd HH:mm:ss'; var date = ...
- FCKeditor插件开发实例:uploadify多文件上传插件
FCKeditor是一个专门使用在网页上属于开放源代码的所见即所得文字编辑器.它志于轻量化,不需要太复杂的安装步骤即可使用.它可和PHP.JavaScript.ASP.ASP.NET.ColdFusi ...
- 记录-Jquery uploadify文件上传实例
原本做的是from表单的文件上传,后来因需要用ajax异步,so接触到了Jquery uploadify上传 贴上代码,以供参考 需要引入的js文件 <link href="../re ...
- [Asp.net]通过uploadify将文件上传到B服务器的共享文件夹中
写在前面 客户有这样的一个需求,针对项目中文档共享的模块,客户提出如果用户上传特别的大,或者时间久了硬盘空间就会吃满,能不能将这些文件上传到其他的服务器?然后就稍微研究了下这方面的东西,上传到网络中的 ...
- Struts2 + uploadify 多文件上传完整的例子!
首先,我这里使用的是 Jquery Uploadify3.2版本号 导入相关的CSS JS <link rel="stylesheet" type=" ...
随机推荐
- Kali Linux入坑之基本配置(2018.1)
我在?天前就决心如Kali的坑,然而安装kali呀vm tools呀更新呀弄了好几天.期间出现的各种问题在此汇总一下. 1.Kali的安装版本选择 在官网上看到的这么多Kali版本应该怎么选呢,在网上 ...
- python之list和tuple
https://www.cnblogs.com/evablogs/p/6691743.html list和tuple区别: 相同:均为有序集合 异同:list可变,tuple一旦初始化则不可变 lis ...
- [idea] SpringBoot整合swagger2实现CRUD
一:创建SpringBoot ,在pom.xml文件中加入jar包 <dependency> <groupId>io.springfox</groupId> < ...
- 试试Linux下的ip命令,ifconfig已经过时了
linux的ip命令和ifconfig类似,但前者功能更强大,并旨在取代后者.使用ip命令,只需一个命令,你就能很轻松地执行一些网络管理任务.ifconfig是net-tools中已被废弃使用的一个命 ...
- 在Bootstrap开发框架中使用Grid++报表
之前在随笔<在Winform开发中使用Grid++报表>介绍了在Winform环境中使用Grid++报表控件,本篇随笔介绍在Bootstrap开发框架中使用Grid++报表,也就是Web环 ...
- ASP.NET Core 2.2 十九. Action参数的映射与模型绑定
前文说道了Action的激活,这里有个关键的操作就是Action参数的映射与模型绑定,这里即涉及到简单的string.int等类型,也包含Json等复杂类型,本文详细分享一下这一过程.(ASP.NET ...
- 菜鸟学IT之python网页爬取初体验
作业来源:https://edu.cnblogs.com/campus/gzcc/GZCC-16SE1/homework/2881 1. 简单说明爬虫原理 爬虫简单来说就是通过程序模拟浏览器放松请求站 ...
- pytorch错误:RuntimeError: received 0 items of ancdata解决
版权声明:本文为博主原创文章,欢迎转载,并请注明出处.联系方式:460356155@qq.com RuntimeError: received 0 items of ancdata错误是在datalo ...
- JSON获取地址
JSON获取地址一: https://github.com/stleary/JSON-java JSON获取地址二: http://genson.io/ JSON获取地址一: https://code ...
- 关于echarts.js 柱形图
echarts.js官网: http://www.echartsjs.com/index.html 这是我所见整理最详细echarts.js 柱形图博客: https://blog.csdn.net/ ...