0

I'm trying to upload a file to my website using a method I found on the net. When i upload files in debug mode, it works fine, but when I try to upload on my website, I get this error.

Access to the path 'D:\Hosting\11029316\html\gizmoblog\Content\Images\dpi.jpg' is denied.

This is the method I'm using to upload files.

public ActionResult UpdateLogo(HttpPostedFileBase SiteLogo)
{
   if (SiteLogo.ContentLength > 0)
   {
       var fileName = Path.GetFileName(SiteLogo.FileName);
       var path = Path.Combine(Server.MapPath("~/Content/Images"), fileName);
       SiteLogo.SaveAs(path);
   }
}

Is there a way I can upload the file using a FTP stream? Or even upload them using a URI to my website like http://www.weburl.com/uploads/filename? Really need help guys..

1 Answer 1

1

This is a permissions issue on your server. On your local machine you are running under the context of your current user, which allows you to write to your disk. On the server, the IIS worker process needs permission to write to the uploads directory (it is not allowed by default for security). See this link for more information

http://support.microsoft.com/kb/979124

To answer your other questions, uploading via an FTP stream is more complex and not necessary since the .NET framework includes everything you need to accept a file upload and save it.

You might also be interested in trying out http://filepicker.io which offers a simple way to handle file management through an API.

Sign up to request clarification or add additional context in comments.

1 Comment

I will check these out! Thanks pal

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.