I know this is old, but it’s got no real answer assigned.
I ran into this issue, and by debugging server logs arrived at this solution:
- upload your image to the
/basepath/uploads
directory.
- ensure your Web Server user account has Read access to the file
- Specify your image location as
url('../../../../uploads/filename');
in the PHP template (assuming a template location of /basepath/application/views/invoice_templates/pdf/
If your template location is different, count back the number of directories to the
/basepath/
, and insert
../
for each level you need to go up to reach the
/basepath
. I am using this technique to add images within the PHP template and also from the custom-pdf.css file
<techie tl/dr for below>
Keeping things local is good for security and accountability. Be safe, y’all!
<Non-techies, This is why you should avoid using “image hosting sites” etc>
Having to host images externally is risky, especially with something like an invoice. Whilst the “emailed” PDF will be fine, if you allow clients to access the invoice online, the invoice assets are redrawn when the “Download PDF” link is clicked. Say you change the image temporarily for a promotion; in the meantime Later that year, Alice is disgruntled with your company, accesses your image host and swaps out the “promotion” image for something indecent.
Client B has lost their invoice, which shows they were entitled to your promotion. Cynthia at Client B decides to retrieve the invoice, clicks “Download PDF” and sees a different angle of Santa’s Sleighbells.
Whilst this risk is still present on a locally-contained system, you have greater traceability. Your clients should have faith in your invoicing system. By keeping the images local, you are showing a greater level of care for your client data by reducing your attack footprint; who wants to have to maintain two systems when they can maintain one!
Congratulations on making it this far. I applaud you