我正在使用 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/。
下面的控制器动作被触发,但正如上面提到的,用户对象没有被传递。
任何帮助表示赞赏!
看法
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");
}