0
로컬 서버에서 asp.net mvc의 폴더에 그림이 저장 중이며 제대로 작동하고 이미지는 폴더에 저장되지만 서버 이미지에는 저장됩니다. 문제에 대해 잘 모르는 폴더에는 저장되지 않지만 사진 제품이 없으면 서버에도 성공적으로 업로드됩니다. 여기에 폴더에 사진을 저장하는 코드가 있습니다.이미지가 서버 ASP.NET의 폴더에 저장되지 않았습니다. C# MVC
public ActionResult Package(PackageDO model, HttpPostedFileBase file)
{
try
{
if (file != null)
{
fileName = System.Guid.NewGuid().ToString() + System.IO.Path.GetExtension(file.FileName);
string physicalPath = Path.Combine(Server.MapPath("~/Images/Uploads/" + fileName));
// save image in folder
file.SaveAs(physicalPath);
}
}
}
내보기 미리
같은@using (Html.BeginForm("Package", "Admin", FormMethod.Post, new { enctype = "multipart/form-data", id = "form1" }))
{
<input type="file" id="file" name="file">
}
감사를 보인다.
당신이''대체는 Server.MapPath'와 Path.Combine (는 Server.MapPath ("~/이미지/업로드 /"+ fileName에)) '("이미지/업로드 /"+ fileName에) 수
감사합니다 다시 해봐? –
나는 또한 노력했지만 작동하지 않았다. –
오류가 발생합니까? –