图片的URL是正确的,但图像不显示 [英] Image URL is correct but image not showing
问题描述
我对GoDaddy的一个网站。所有的权限设置是否正确,图像确实存在。然而,当页面加载图像选定不显示该项目。这里是我的code
I have a website on GoDaddy. All permissions are set correctly and the image DOES exist. However when the page loads the image for the item selected does not show. Here is my code
imagepath = "~/spaimages/" + currentSpaModel.Name.ToString() + ".png";
if (File.Exists(Server.MapPath(imagepath)))
{ this.spaimage.ImageUrl = Server.MapPath(imagepath); }
spaimage是一个ASP的控制和THR URL的图像设置为是D:\\主持\\ XXXXXXX \\ calspas \\ spaimages \\ modelname.png
spaimage is an ASP control and thr URL that the image is set to is D:\hosting\xxxxxxx\calspas\spaimages\modelname.png
我是什么做错了。
推荐答案
文件路径 D:\\主持\\ XXXXXXX \\ calspas \\ spaimages \\ modelname.png
是文件夹在图像所在的Web服务器上。您发送此作为< IMG>
标签的的src
属性,它告诉浏览器,去获取图像在 D:\\主持\\ XXXXXXX \\ calspas \\ spaimages \\ modelname.png
。浏览器无法熄灭到Web服务器的D盘,所以看起来该文件夹和图像自身的D盘。
The file path D:\hosting\xxxxxxx\calspas\spaimages\modelname.png
is the folder where the image resides on the web server. You are sending this as the <img>
tag's src
attribute, which tells the browser, "Go get the image at D:\hosting\xxxxxxx\calspas\spaimages\modelname.png
." The browser cannot go off to the D drive of the web server, so it looks on its own D drive for that folder and image.
你的意思做的是有&LT; IMG&GT;
标签的的src
属性是路径到文件夹中的网站。你只是那里 - 分配映像路径的ImageUrl
属性时,只是下降的使用Server.Mappath
部分。也就是说,不是,
What you mean to do is to have the <img>
tag's src
attribute be a path to a folder on the website. You're just about there - just drop the Server.MapPath
part when assigning the image path to the ImageUrl
property. That is, instead of:
this.spaimage.ImageUrl = Server.MapPath(imagepath);
执行
this.spaimage.ImageUrl = imagepath;
其是否正常工作。
See if that works.
感谢
这篇关于图片的URL是正确的,但图像不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!