Phần View
Mã:
@using (Html.BeginForm("UpdateImage","UploadFile",FormMethod.Post, new { enctype = "multipart/form-data"}))
{
<div>
<label for="fileUpload">File upload</label>
<input type="file" id="fileUpload" name="fileUpload" />
</div>
<div>
<input type="submit" value="Submit" />
</div>
}
Phần Controller
Mã:
public ActionResult UploadFile()
{
return View();
}
[HttpPost]
public ActionResult UploadFile()
{
foreach (string upload in Request.Files)
{
if (Request.Files[upload].ContentLength == 0) continue;
string pathToSave = Server.MapPath("~/Content/Images/");//Phần vị trí lưu File .
string filename = Path.GetFileName(Request.Files[upload].FileName);
Request.Files[upload].SaveAs(Path.Combine(pathToSave, filename));
ModelState.AddModelError("", "Update thanh cong");
}
return View();
}
View more random threads:
Ngọc Bích xanh bản chất thuộc dòng đá đá hoa (jade). Và cẩm thạch là tên gọi chung của ngọc bích. Vì thực chất chúng thuộc dòng đá đa khoáng được hình thành từ chất Silicat dưới dạng dioxy. Ngọc bích...
Chia sẻ Vòng tay ngọc bích xanh là...