Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload images from ASP.NET to godaddy file system

Tags:

c#

asp.net

I have an Admin panel on my website, which allows a user to upload images to file system. I'm simply doing in C# code:

imageFile.SaveAs(galleryPath + fileName); 

But getting a permissions exception:

Access to the path 'D:\Hosting...\html\Images\Gallery\page2-img1.jpg' is denied.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.UnauthorizedAccessException: Access to the path 'D:\Hosting...\html\Images\Gallery\page2-img1.jpg' is denied.

Can you please give me a tip how can I grant a permissions?

like image 850
Alex Smoke Avatar asked Oct 20 '13 10:10

Alex Smoke


People also ask

How do I upload HTML files to GoDaddy?

Scroll to Websites + Marketing and select Manage next to your website to open your site. Select Edit Website or Edit Site to open your website builder. Go to the page and location you want to add your custom code, and add a section. Search for the HTML section and select Add.


1 Answers

Read this troubleshooting article, there is a solution there. If that doesn’t work just contact the support ;)

http://support.godaddy.com/help/article/6481/setting-directory-permissions-with-windows-hosting-accounts

Btw, its better practice to use Path.Combine when concatenating folder+file name

imagefile.SaveAs(System.IO.Path.Combine(galleryPath, fileName));
like image 136
Vali Alexandrescu Avatar answered Oct 21 '22 06:10

Vali Alexandrescu