Last post Dec 11, 2020 11:11 AM by PatriceSc
Nov 26, 2020 09:09 PM|masterdineen|LINK
I have a Web App that is deployed onto an FTP all works fine, but errors out when an image cannot be found.
all images are held within a folder called images. so an example full path on the ftp for am image would be
XImage LogoImage = XImage.FromFile(@"/public_html/Images/ImageName.PNG");
Nov 27, 2020 07:57 AM|yij sun|LINK
Accroding to your description,I have some question.
1.Where do you load the image?
2.What kind of application you are using?
3.What's the error code while you are loading the image?
4.Which permissions you have assign to the image folder?
5.How you deploy the application in iis?
I suggest you make sure image with the given file name is existed at the place. Try to use the absolute file path from the root of drive C:. suggest to check the iis log.
Nov 27, 2020 09:26 AM|masterdineen|LINK
Hello Yijing Sun
as mentioned in my post, all the images are held within a folder called Images on the ftp. So i just wanted know how to reference an image
within the C# (behind code)????
Dec 11, 2020 08:44 AM|yij sun|LINK
As far as I think,you need to get the full path.
fullPath = Path.GetFullPath("public_html\\Images\\ImageName.PNG");
XImage LogoImage = XImage.Image.FromFile(fullpath);
Dec 11, 2020 11:11 AM|PatriceSc|LINK
If ASP.NET 4.x try (assuming the path relative to your web app is the same):
XImage LogoImage = XImage.FromFile(Server.MapPath(@"~/public_html/Images/ImageName.PNG"));
It seems to be a class that is loading an image from the file system so you need to use Server.MapPath to get a physical path rather than a path relative to a ftp or web root (as a physical path it is a "public_html" et the root of the curent drive).