0
지정된 경로의 형식은 지원되지 않습니다.이미지 URL이 데이터베이스에 저장되고 있지만 VS2015의 지정된 폴더에 이미지가 저장되지 않았습니다.
Path.Combine을 사용하려고 시도했지만 경로에서 '~'가 제거되었지만 이미지는 여전히 "Images"폴더에 저장되지 않습니다.
[HttpPost]
public ActionResult Create(PropertyViewModel propertyViewModel)
{
if (ModelState.IsValid)
{
Property property = new Property();
property.Id = propertyViewModel.Id ?? 0;
property.PropertyCost = propertyViewModel.PropertyCost;
property.PropertyDescription = propertyViewModel.PropertyDescription;
HttpPostedFileBase fup = Request.Files["PropertyImage"];
if(fup!=null)
{
property.PropertyImage = fup.FileName;
fup.SaveAs(Server.MapPath("~/Images/" + fup.FileName));
//string path = "~/Images/"+fup.FileName;
////string combinedPath = System.IO.Path.Combine(path,fup.FileName);
//fup.SaveAs(Server.MapPath(path));
}
_propertyQueryProcessor.Create(property);
}
return RedirectToAction("Index");
}
'Server.MapPath ("~/Images /"+ fup.FileName')의 값은 무엇입니까? –
그리고 관련이 없지만 뷰 모델을 사용하고 있기 때문에'HttpPostedFileBase PropertyImage' 속성을 포함해야합니다. 모델 –
ViewModel의 속성은 public string PropertyImage –