简体   繁体   English

从asp.net网站保存图像

[英]Save a image from asp.net website

,Hope i get this clear. ,希望我明白这一点。

I have a asp.net website, as part of it i generate a bitmap and need to save it some were so i can display it later on. 我有一个asp.net网站,作为它的一部分,我生成了一个位图,需要将其保存一些,以便以后可以显示它。

for now my sites is locate here: 现在我的站点位于这里:

http://tools.myDomain.com/mySite/

I have created a directory with in my site: 我在自己的网站中创建了一个目录:

http://tools.myDomain.com/mySite/img/

Now i am trying to save my bitmap to there like this: 现在,我试图像这样将我的位图保存到那里:

bitmap.Save(@"http://tools.myDomain.com/mySite/img/bitmap.png");

I can get this to work, not from my computer locally and not when i do Publish to my site... 我可以使它正常工作,而不是从本地计算机运行,也可以在发布到我的站点时工作...

Any ideas how can i fix this problem? 任何想法我该如何解决这个问题?

Thank you 谢谢

您需要将其保存在服务器上而不是网络上

bitmap.Save(HttpContext.Current.Server.MapPath("/img/bitmap.png"));

try 尝试

bitmap.Save(Server.MapPath("/mySite/img/bitmap.png"));

Or you can use an absolute path 或者您可以使用绝对路径

bitmap.Save("c:\inetpub\wwwroot\mySite\img\bitmap.png");

Note that the path is just an example and should be your absolute path. 请注意,该路径仅是示例,应该是您的绝对路径。

You need to add permissions for ASPNET user. 您需要为ASPNET用户添加权限。 It will work for sure. 它肯定会工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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