怎么在Asp.netMVC中使用swupload实现多图上传功能-创新互联
本篇文章为大家展示了怎么在Asp.net MVC中使用swupload实现多图上传功能,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

1. 下载WebUploader
2. 将下载到的压缩包里面的文件复制到自己的项目中
3. 添加引用
4.准备一个放图片的容器和一个上传按钮
5.创建Web Uploader实例并监听事件
6 在Controller里新建一个Action用于保存图片并返回图片路径(这方法是 eflay 前辈博客上说的)
public ActionResult UpLoadProcess(string id, string name, string type, string lastModifiedDate, int size, HttpPostedFileBase file)
{
string filePathName = string.Empty;
string localPath = Path.Combine(HttpRuntime.AppDomainAppPath, "Upload");
if (Request.Files.Count == 0)
{
return Json(new { jsonrpc = 2.0, error = new { code = 102, message = "保存失败" }, id = "id" });
}
string ex = Path.GetExtension(file.FileName);
filePathName = Guid.NewGuid().ToString("N") + ex;
if (!System.IO.Directory.Exists(localPath))
{
System.IO.Directory.CreateDirectory(localPath);
}
file.SaveAs(Path.Combine(localPath, filePathName));
return Json(new
{
jsonrpc = "2.0",
id = id,
filePath = "/Upload/" + filePathName
});
}上述内容就是怎么在Asp.net MVC中使用swupload实现多图上传功能,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注创新互联行业资讯频道。
名称栏目:怎么在Asp.netMVC中使用swupload实现多图上传功能-创新互联
标题路径:http://www.jxjierui.cn/article/dssecp.html


咨询
建站咨询
