Reputation: 11725
I am trying to work out the example from http://haacked.com/archive/2008/05/10/writing-a-custom-file-download-action-result-for-asp.net-mvc.aspx, however, I am having the error message:
Access to the path 'C:\Dev\myproject\zippedFile' is denied.
or can I have an example of file downloading in MVC
Help please. Thanks
Upvotes: 1
Views: 730
Reputation: 6294
In your controller:
[HttpPost]
public ActionResult Upload(HttpPostedFileBase file)
{
if (file != null)
{
file.SaveAs("file path goes here" + file.FileName);
}
return View();
}
In your view:
@using (Html.BeginForm("Upload", "ControllerName", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<input type="file" name="file" />
<input type="submit" value="Upload" />
}
And like Mathieu says, make sure where ever you are storing the files, your worker process has access to it. Best bet is to store the files within the site /Upload
for example.
Upvotes: 0
Reputation: 31192
ASP.NET application pool identity (SYSTEM\NETWORK SERVICE by default) must have read access to the directory holding the file(s).
Upvotes: 3