我有一个ASP.NET网站。 该网站有一个按钮,可让您在网站上加载您的照片,并且在我的本地计算机上运行时没有任何问题。 但在服务器上,当我想上传图片时,我发现了一个异常。 这是我抓住的例外:
访问路径'C:\ inetpub \ vhosts \ u0270481.plsk.regruhosting.ru \ httpdocs \ ps-plus.pro \ UsersIcons \ 259b60ca-16de-4168-8b45-900f7078bcea.png'被拒绝。
有一个我使用的代码:
FileUpload1.SaveAs(Server.MapPath(String.Format("UsersIcons/{0}", userIcoName)));I have an ASP.NET web site. The site has a button that allows you to load your photo on the website and it works without any problems on my local computer. But on server when I want to upload an image, I catch an exception. This is the exception that I catch:
Access to the path 'C:\inetpub\vhosts\u0270481.plsk.regruhosting.ru\httpdocs\ps-plus.pro\UsersIcons\259b60ca-16de-4168-8b45-900f7078bcea.png' is denied.
There is a code I use:
FileUpload1.SaveAs(Server.MapPath(String.Format("UsersIcons/{0}", userIcoName)));最满意答案
asp.net网站可以与给定Windows用户(可能是用户帐户,而不是管理员)一起工作,因此,当该用户尝试访问服务器C路径/或您设置的任何路径时,该驱动器不允许该用户从该路径复制,你会得到这个例外。
您可以通过文件向该用户添加权限,然后就可以工作。
The asp.net website works with a Windows given user (a user account, not an administrator, likely) so, when that user tries to access the server C path/or whatever path you set it, and that drive does not allow that user to copy from that path, you'll get that exception.
You can add permission to that user over your file and then it'd work.
更多推荐
发布评论