如何在asp.net网站上加载文件(how to load files on asp.net website)

编程入门 行业动态 更新时间:2024-10-24 13:27:00
如何在asp.net网站上加载文件(how to load files on asp.net website)

我有一个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.

更多推荐

本文发布于:2023-08-03 01:31:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1382476.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   文件   如何在   网站   asp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!