<script src="../jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="../jquery.flash.js" type="text/javascript"></script>
<script src="../jquery.jqUploader.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#example3").jqUploader({ background: "FFFFDF", barColor: "FF00FF",
allowedExt: "*.zip",
src: "../jqUploader.swf",
uploadScript : "@Url.Action("Upload","Car")",
afterScript : onRequestCompleted
});
});
</script>
<form action="@Url.Action("Upload","Car")" class="a_form">
<div id="example3"></div>
</form>
///////////action A
public string Upload(HttpPostedFileBase fileData)
{
if (this.Request.Files.Count == 0)
{
return "";
}
var fileName = this.Server.MapPath("~/AAA/" + System.IO.Path.GetFileName(fileData.FileName));
fileData.SaveAs(fileName);
return "ok";
}
/////I used this code in 2 place. In first I used in HomeController/Upload action A, and Html part in Home/Index.cshtml.Then jqUploader working. Bat when I moved codes: action A in Areas/AdminPanel/Controllers/CarController.cs and html in Areas/AdminPanel/Views/Car/__Extract.cshtml the jQUploader don't work and get Http #302 error.
////This code works when I use the new MVC project. But when I want to use in my project, gives error # 302. I think it's from Global.asax.cs, and I do not know how to solve this problem . Who can say 开发者_如何学运维why there might be?
HTTP Status code 302 means your server is redirecting you to somewhere else. Find out where, by using firebug, and let me know. Also you may need to add the attribute [HttpPost]
to your Upload action.
The most common reason for redirection is when you are not logged in and trying to access admin features. (I suspect this from looking at path Areas/AdminPanel/Views/Car/
) Then the server will redirect you to login page.
Check if Authorize
attribute is listed in Global Filter in Global.asax.cs or on top of your action Upload
. If so login, then upload.
If you are logged in then check if this jqUploader is sending the auth cookie, again, use firebug net panel XHR tab to find out all this.
精彩评论