I am trying to build an uploader with ASP.NET MVC, but I'm having a bit of a problem.
The uploader occurs in a private pane that is loaded by jQuery - that is to say, it is it's own view, but it is not accessible via a View Path. Or it is not intended to be - either way, I need the page not to change once the upload is complete.
Is there any way to do this?
[AcceptVerbs(HttpVerbs.Post)]
public void FileUpload(HttpPostedFileBase uploadFile)
{
if (uploadFile.ContentLength > 0)
{
string filePath = Path.Combine(HttpContext.Server.MapPath("/Uploads"),
Path.GetFileName(uploadFile.FileName));
uploadFile.SaveAs(filePath);
}
}
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<script type="text/javascript">
$(function() {
$("#tabs").tabs();
});
</script>
<div id="tabs">
<ul>
<li><a href="#create">Upload</a></li>
</ul>
<div id="create">
<h2>
FileUpload</h2>
<% using (Html.BeginForm("FileUpload", "Management",
FormMethod.Post, new { enctype = "multipart/form-data" }))
{%>
<input name="uploadFile" type="file" />
<input type="submit" value="Upload File" />
<%} %>
</div>
</div>