mvc api 및 콘솔 응용 프로그램에서 서비스로 사용하고 있습니다.콘솔에서 mvc로 파일 보내기
MVC의 코드는 다음과 같습니다
[HttpPost]
public ActionResult Index(HttpPostedFileBase file)
{
if (file.ContentLength > 0)
{
var fileName = System.IO.Path.GetFileName(file.FileName);
var path = System.IO.Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
file.SaveAs(path);
}
return RedirectToAction("Index");
}
내가 다른 접근을 시도하고 내가 MVC 측면에서 file == null
에 불과, 어떤 도움을받을 수 없다?
콘솔 응용 프로그램에서 요청을 작성한 방법을 설명 할 수 있습니까 (코드 표시 가능)? – GolfWolf
은 요청입니다. 파일이 채워 졌습니까? – Pbirkoff
파일이 실제로 메서드로 전달되었는지 확인 했습니까? 길이가 실제로 0보다 큰지? 편집 : 이 [Phil Haack의 블로그 게시물] (http://haacked.com/archive/2010/07/16/uploading-files-with-aspnetmvc.aspx)이 질문에 대한 대답 인 것 같습니다. – crunchy