本篇文章為大家展示了怎么在Asp.net MVC中使用swupload實現(xiàn)多圖上傳功能,內(nèi)容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。
1. 下載WebUploader
2. 將下載到的壓縮包里面的文件復制到自己的項目中
3. 添加引用
4.準備一個放圖片的容器和一個上傳按鈕
5.創(chuàng)建Web Uploader實例并監(jiān)聽事件
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 }); }
上述內(nèi)容就是怎么在Asp.net MVC中使用swupload實現(xiàn)多圖上傳功能,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道。