0
사용자가 파일을 제출할 수있는 부분보기가 있습니다.파일 업로드 버튼을 클릭하면 부분보기 만 업데이트됩니다.
<form action="Attachments" method="post" enctype="multipart/form-data" target="_self">
<div>
<label style="text-align: left;">Add File:</label>
</div>
<div>
<input type="file" name="file" id="file" style="width: 275px;" />
</div>
<div style="text-align: right;">
<input type="submit" value="Add"/>
</div>
</form>
이것은 HTTPPost
[HttpPost]
public ActionResult Index(HttpPostedFileBase file)
{
if (file.ContentLength > 0)
{
var fileName = Path.GetFileName(file.FileName);
var path = Path.Combine("C:\\Attachments", fileName);
file.SaveAs(path);
return AddAttachment(fileName);
}
return RedirectToAction("Failed", "Attachments");
}
addAttachment 반환 "반환 RedirectToAction에 대한 AttachmentsController 메소드를 호출합니다 ("색인 ","첨부 파일 ");" 이 모든 작업을 수행 한 후 첨부 파일을 추가하면 전체 화면이 새로 고쳐지고 첨부 파일 추가를위한 부분보기 만 새로 고침됩니다. 이걸 어떻게하면 돼?!