uploadify를 사용하여 컨트롤러 메서드에서 사용자 파일을 자동 제출합니다. Request.Files [ "Name"]은 null을 계속 반환하지만 request.form은 null이 아니며, 내가 breakpoint를 설정하고 그것을 디버깅 할 때 request.form에있는 파일. 내가 놓친 게 있니? 나는 이것을 mvc2에서 테스트하고 있지만 mvc4에서 사용할 계획이다.Request.Files [ ""] null을 계속 반환합니다.
<link href="../../Content/uploadify.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="../../Scripts/jquery.uploadify.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$('#file_upload').uploadify({
'swf': '/Content/uploadify.swf',
'uploader': '/Home/UploadFile',
'auto': true
// Your options here
});
});
</script>
</head>
<body>
<%--<% using (Html.BeginForm("UploadFile", "Home", FormMethod.Post,
new { enctype = "multipart/form-data" }))
{ %>--%>
<input type="file" name="file_upload" id="file_upload" style="margin-bottom: 0px" />
<%-- <% } %>--%>
컨트롤러 방법 : 내가 제출 버튼을 추가 한 다음 제출하면
[HttpPost]
public ActionResult UploadFile(HttpPostedFileBase file)
{
var theFile = Request.Files["file_upload"];
return Json("Success", JsonRequestBehavior.AllowGet);
}
그래도 작동합니다. 제출 버튼없이 자동으로해야합니다.
저는 uploadify에 익숙하지 않습니다. 그러나 폼이있을 때 명시 적으로 POST 메서드를 사용하고 작업 메서드는 POST 요청에 응답하는 것처럼 보입니다. 업로드가 GET을 할 수 있습니까 ??? –