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 is an ASP control and thr URL that the image is set to is D:\hosting\xxxxxxx\calspas\spaimages\modelname.png
What am I doing wrong.
The file path
D:\hosting\xxxxxxx\calspas\spaimages\modelname.pngis the folder where the image resides on the web server. You are sending this as the<img>tag’ssrcattribute, which tells the browser, “Go get the image atD:\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.What you mean to do is to have the
<img>tag’ssrcattribute be a path to a folder on the website. You’re just about there – just drop theServer.MapPathpart when assigning the image path to theImageUrlproperty. That is, instead of:Do:
See if that works.
Thanks