您的位置:首页 > 其它

图片上传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/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: