로컬 컴퓨터에서 아래 코드는 제대로 작동하지만 원격 서버에서 호스팅 할 때 이미지 파일을 찾지 못하는 것 같습니다. Image 폴더를 생성하고 읽기/쓰기 권한도 부여했습니다.ASP.NET MVC 3.0에서 이미지를 업로드 할 때 오류가 발생했습니다.
// ------------------------------ --------------
오류
Server Error in '/' Application.
Could not find file 'IdImage.jpg'.
설명 : 처리되지 않은 예외가 현재 웹 요청을 실행하는 동안 일어났다. 오류 및 코드에서 시작된 위치에 대한 자세한 정보는 스택 추적을 검토하십시오.
Exception Details: System.IO.FileNotFoundException: Could not find file 'IdImage.jpg'.
코드 ---------------------------------
// 다음과 같다 ------------
[HttpPost]
public ActionResult Index(HttpPostedFileBase file)
{
if (file != null && file.ContentLength > 0)
{
var fileName = Path.GetFileName(file.FileName);
var path = Path.Combine(Server.MapPath("~/Images/Photo"), fileName);
file.SaveAs(path);
}
return RedirectToAction("Index");
}