Reference img path - ubuntu - <img> tag



  • I'm cloning my local jsreport out to an ubuntu server and my logo references broke in the process.

    I'm not a proficient linux user at all - if I have a logo sitting in /jsreportapp/data/logo.png and I want a report to display it by doing
    <img background-color:transparent src = "logo.png" style="width:260px;"</img>

    Can anyone help me with what the path in that tag would need to be? I feel like I've tried every thing I could think of:

    logo.png by itself
    /data/logo.png (really thought this would have been the answer)
    /jsreportapp/data/logo.png
    /home/ubuntu/jsreportapp/data/logo.png...which is pretty much all the way down.

    When this was on my mac it was totally fine but this move has messed it all up.

    I have tried to make this an asset but i couldn't get it to work that way.

    Thank you



  • Option 1
    You need to have "allowLocalFilesAccess": true in the config to allow jsreport reach your local files.
    The file you want to reach needs to have proper linux permissions so the user running the jsreport can read it.
    Then the following should work then:

    <img src="{{__rootDirectory}}data/logo.png"</img>
    <img src="/home/ubuntu/jsreportapp/data/logo.png"</img>
    

    Option 2
    Use the following configuration

     "extensions": {  
        "assets": {
          "allowedFiles": "**/*.*",
          "searchOnDiskIfNotFoundInStore": true
        }
      }
    

    And use the asset syntax to get an image.

    <img src="{#asset data/logo.png @encoding=dataURI}"</img>
    

    Option 3 (the preferred one)
    Upload the image as an asset through the studio and use the {#asset ...} syntax.

    https://jsreport.net/learn/assets



  • Thank you. This helped get it working again.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.