을 업로드 :MVC 파일이 코드가 UnauthorizedAccessException
양식에서 업로드 한 사진을 촬영하고 서버 (로컬 서버)에 저장하기위한 것입니다[HttpPost]
public ActionResult Edit(Photograph photo, HttpPostedFileBase image)
{
if (ModelState.IsValid)
{
if (image != null)
{
byte[] imageData = new byte[image.ContentLength];
image.InputStream.Read(imageData, 0, image.ContentLength);
System.IO.File.WriteAllBytes(HttpContext.Server.MapPath("~/Content/Images"), imageData);
}
repository.SavePhotograph(photo);
TempData["message"] = string.Format("{0} has been saved", photo.Name);
return RedirectToAction("Index");
}
else
{
return View(photo);
}
}
. 모든 프로젝트가 네트워크 서비스 사용자 권한과 IIS_IUSRS 그룹 권한으로 유지되는 폴더 "Visual Studio 2010"을 제공했습니다. 저는 또한 관리자로서 Visual Studio를 운영하고 있습니다.
어떤 이유로 나는 그 위치에 파일을 저장할 수 없습니다. 위치는 {Project_Name \ Content \ Images} 아래의 프로젝트 폴더 내에 있습니다. 파일을 저장하려면 어떻게해야합니까?
감사합니다, 그것은 아직도 날 그 위치에 파일을 저장할 수없는 몇 가지 이유
Visual Studio에서 디버그 모드로 실행 중이거나 IIS에 배포 중입니까? – curtisk