Hello SO:
I am attempting to upload files to my server using ASP.NET MVC. Here is the code that handles the upload request:
foreach (string file in Request.Files)
{
var hpf = Request.Files[file];
if (hpf.ContentLength == 0)
{
continue;
}
var savedFileName = Path.Combine(@"~/uploads", Path.GetFileName(hpf.FileName));
hpf.SaveAs(Server.MapPath(savedFileName));
}
I keep getting this error:
Access to the path 'C:\HostingSpaces\andersle\anders-leet.com\wwwroot\uploads\{filename}' is denied.
I set the permissions of the upload folder to 777, so from that end it should be OK. Would I have to talk to my hosting company about other permissions (since this is ASP.NET)?
Or is my upload logic completely wrong?
Thanks!