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?
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.
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));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With