Image does not show up
-
Hi, I created a ASP.NET page using C# to display images. The problem how ever is that on my local computer I can see all the images in the Image Box (from the toolbox of VS.NET) but no image is displayed when the application in hosted!! Any help is appreciated. I am going to attach a sample of the code below. Main_load( .....) { System.Web.UI.WebControls.Image _image = new Image(); filenames = Directory.GetFiles(Server.MapPath("./Photos")); _image.ImageUrl = Server.MapPath("./Photos/" + Path.GetFileName(url)); } The images are in the folder called Photos. Thanks, Sandeep
-
Hi, I created a ASP.NET page using C# to display images. The problem how ever is that on my local computer I can see all the images in the Image Box (from the toolbox of VS.NET) but no image is displayed when the application in hosted!! Any help is appreciated. I am going to attach a sample of the code below. Main_load( .....) { System.Web.UI.WebControls.Image _image = new Image(); filenames = Directory.GetFiles(Server.MapPath("./Photos")); _image.ImageUrl = Server.MapPath("./Photos/" + Path.GetFileName(url)); } The images are in the folder called Photos. Thanks, Sandeep
you need to use relative file locations. Especially since its hosted by someone else. I guarantee you cant access thier file systen. For instance if all the images are in a folder called images from the web app src="../images/myimage.gif" Nick 1 line of code equals many bugs. So don't write any!!
-
you need to use relative file locations. Especially since its hosted by someone else. I guarantee you cant access thier file systen. For instance if all the images are in a folder called images from the web app src="../images/myimage.gif" Nick 1 line of code equals many bugs. So don't write any!!
-
Thanks Nick. For some reason Server.MapPath did not work. Anyways i just replace it by ./Photos as u mentioned and it worked. Any idea why Server.MapPath didnt work?
Thats because the MapPath gets the physical path. On host servers for the company providers, often thier virtual ghost partitions. So, theres not really an actual path to find. So do everything as relative to the Web Root Nick 1 line of code equals many bugs. So don't write any!!