locked
Unable to reference image on Web App deployed on FTP RRS feed

  • Question

  • User2037455357 posted

    Hello there

    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

    /public_html/Images/Kaizen_RiskAssessment_Logo.PNG

    C# example

    XImage LogoImage = XImage.FromFile(@"/public_html/Images/ImageName.PNG"); 

    Regards

    Rob

    Thursday, November 26, 2020 9:09 PM

All replies

  • User1535942433 posted

    Hi masterdineen,

    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.

    Best regards,

    Yijing Sun

    Friday, November 27, 2020 7:57 AM
  • User2037455357 posted

    Hello Yijing Sun

    1. The image is being loaded into a pdf
    2. the application is an asp.net build
    3. Image does not exist
    4. Application has been deployed onto FTP.

    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)????

    Friday, November 27, 2020 9:26 AM
  • User1535942433 posted

    Hi masterdineen,

    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);

    Best regards,

    Yijing Sun

    Friday, December 11, 2020 8:44 AM
  • User753101303 posted

    Hi,

    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).

    Friday, December 11, 2020 11:11 AM