public ActionResult Upload(HttpPostedFileBase file, Album obj) { try { if (file != null && file.ContentLength > 0) { string fileName = Path.GetFileNameWithoutExtension(file.FileName); fileName += "_" + obj.IdAlbum; fileName += Path.GetExtension(file.FileName); string folderPath = Server.MapPath("~") + @"\Assets\images\ImagesOutSource\ImagesSong"; if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } string path = Path.Combine(folderPath, fileName); file.SaveAs(path); var dao = new AlbumDAO(); dao.Upload(obj.IdAlbum, fileName); } else { ModelState.AddModelError("", "Bạn phải nhập vào trường này"); } } catch (System.Exception) { return(View(obj)); } return(View()); }