简体   繁体   中英

ASP.Net file uploade has error “ Access Denied”

I am using ASP.Net 4.5 and authentication in my website and I have an admin folder just for admin but when the admin is logged in and I want to upload images the page error is:

Access to the path 'C:\Inetpub\...\secdescimg\65ed367d-9526-4b14-842c-4e10c2845d03.jpg' is denied.  

"secdescimg" this folder is not in admin folder and the uploade is user control, i moved both to the admin folder by dragging, but this error occurs again.

Right-Click the folder, go to Properties, Security tab, make sure the local ASPNET account has Read and Write permissions on that folder. If not, Add local ASPNET account to the list and give it read and write permissions. Click OK.

更新:

It's beacause the problem is that ASPNET user or NETWORK SERVICE user (both are user accounts on the server, which ASPNET uses to authorize for the OS) need to have permissions to write the file to aforementioned location.

Account need the permissions to the folder where file is written (the file isn't there before uploading, of course), so user of course doesn't set any permissions to anywhere but server admninistrator does to 'D:\\inetpub\\mywebfolder\\subfoldername dir in this case (I might suggest specifying a location outside web folders in case they are not supposed to be downloaded just like that)

Writing something is stronger permission than just reading so, admin needs to give the write permission in order to enable file uploading if you want to save it straight to server's hard disk.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM