我正在使用SWFUpload在ASP.NET MVC 1.0網站上進行文件上傳。它工作正常,但我無法驗證上傳方法。 HttpContext.User.Identity.Name返回一個空字符串。我假設這是因爲Flash電影正在發佈。我也使用這裏提供的包裝:http://blog.codeville.net/2008/11/24/jquery-ajax-uploader-plugin-with-progress-bar/。SWFUpload身份驗證
下面的控制器操作被觸發,但如上面提到的,用戶對象沒有通過。
任何幫助表示讚賞!
查看
HTML
<form enctype="multipart/form-data" method="post" action="/Media/Upload/Photo">
<input type="file" id="userPhoto_Photo" name="userPhoto_Photo" />
</form>
的Javascript
$(function() {
$("#userPhoto").makeAsyncUploader({
upload_url: '/Media/Upload',
flash_url: '<%= Url.Content("~/Content/Flash/swfUpload-2.2.0.1.swf") %>',
file_size_limit: '1 MB',
file_types: '*.jpg; *.png; *.gif',
button_action: SWFUpload.BUTTON_ACTION.SELECT_FILE,
button_width: 210,
button_height: 35,
button_image_url: '<%= Url.Content("~/Content/Images/UploadPhoto.png") %>',
button_text: '',
button_cursor: SWFUpload.CURSOR.HAND,
button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT
});
});
控制器動作
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Upload()
{
if (Request.Files.Count == 1)
{
//Upload work
}
return RedirectToAction("Index", "Profile");
}
我認爲你的方式可能會導致安全問題〜 – Maidot 2011-05-03 07:15:37