图片上传uploadify
2016-04-22 13:54
288 查看
图片上传借用js Uploadify,支持多张图片上传
1、下载Uploadify.js 地址http://www.uploadify.com/download/
2、前台页面
<span id="uploadify">上传多张图片</span>
<script src="~/uploadfy/jquery-2.2.0.min.js"></script>
<script src="~/uploadfy/uploadify.min.js"></script>
<script type="text/javascript">
$('#uploadify').uploadify({
uploader: '../../Index/Upload', // 服务器端处理地址
swf: '../../uploadfy/uploadify.swf', // 上传使用的 Flash
width: 60, // 按钮的宽度
height: 23, // 按钮的高度
buttonText: "上传", // 按钮上的文字
buttonCursor: 'hand', // 按钮的鼠标图标
fileObjName: 'Filedata', // 上传参数名称
// 两个配套使用
fileTypeExts: "*.jpg;*.png", // 扩展名
fileTypeDesc: "请选择 jpg png 文件", // 文件说明
auto: true, // 选择之后,自动开始上传
multi: true, // 是否支持同时上传多个文件
queueSizeLimit: 5 // 允许多文件上传的时候,同时上传文件的个数
});
</script>
3、后台接受、存储
public ActionResult Upload(HttpPostedFileBase Filedata)
{
// 如果没有上传文件
if (Filedata == null ||
string.IsNullOrEmpty(Filedata.FileName) ||
Filedata.ContentLength == 0)
{
return this.HttpNotFound();
}
// 保存到 ~/photos 文件夹中,名称不变
string filename = System.IO.Path.GetFileName(Filedata.FileName);
string upPath = AppDomain.CurrentDomain.BaseDirectory + "Upload/";
string virtualPath =
string.Format("~/Images/{0}", filename);
string path = Path.Combine(upPath, filename);
Filedata.SaveAs(path);
return this.Json(new { });
}
4、具体参数
查询地址:http://www.uploadify.com/documentation/
1、下载Uploadify.js 地址http://www.uploadify.com/download/
2、前台页面
<span id="uploadify">上传多张图片</span>
<script src="~/uploadfy/jquery-2.2.0.min.js"></script>
<script src="~/uploadfy/uploadify.min.js"></script>
<script type="text/javascript">
$('#uploadify').uploadify({
uploader: '../../Index/Upload', // 服务器端处理地址
swf: '../../uploadfy/uploadify.swf', // 上传使用的 Flash
width: 60, // 按钮的宽度
height: 23, // 按钮的高度
buttonText: "上传", // 按钮上的文字
buttonCursor: 'hand', // 按钮的鼠标图标
fileObjName: 'Filedata', // 上传参数名称
// 两个配套使用
fileTypeExts: "*.jpg;*.png", // 扩展名
fileTypeDesc: "请选择 jpg png 文件", // 文件说明
auto: true, // 选择之后,自动开始上传
multi: true, // 是否支持同时上传多个文件
queueSizeLimit: 5 // 允许多文件上传的时候,同时上传文件的个数
});
</script>
3、后台接受、存储
public ActionResult Upload(HttpPostedFileBase Filedata)
{
// 如果没有上传文件
if (Filedata == null ||
string.IsNullOrEmpty(Filedata.FileName) ||
Filedata.ContentLength == 0)
{
return this.HttpNotFound();
}
// 保存到 ~/photos 文件夹中,名称不变
string filename = System.IO.Path.GetFileName(Filedata.FileName);
string upPath = AppDomain.CurrentDomain.BaseDirectory + "Upload/";
string virtualPath =
string.Format("~/Images/{0}", filename);
string path = Path.Combine(upPath, filename);
Filedata.SaveAs(path);
return this.Json(new { });
}
4、具体参数
查询地址:http://www.uploadify.com/documentation/
相关文章推荐
- UI for iOS(四) -- UIButton添标题文字
- 最全的css Hack
- Brief描述子
- ASP.NET MVC之文件上传【一】
- Navigation Bar上的返回按钮文本颜色,箭头颜色以及导航栏按钮的颜色
- jstree的简单使用例子
- arm:PC=当前执行指令地址+8
- android 系统相册调用,各版本的区别总结
- C# 参考之方法参数关键字:params、ref及out
- 紫书例题11-8(最大流)
- Android学习第二课
- CI 笔记(easyui js命令)
- Android快速开发系列 10个常用工具类
- 泽众2016年4月电子期刊
- RAD Studio, Delphi and C++Builder 10.1 Berlin 新版本功能介绍 - 首场在线教学
- Oracle 11g笔记——Oracle内存结构
- Sublime3安装过程及常用插件安装及常用快捷键
- 4.22
- IOS的 testflight测试设置
- jvm笔记