Online Shopping : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to
Did You Find This Entry Useful?

9 of 16 people (56%) answered Yes
Recently 5 of 10 people (50%) answered Yes


How do I include a .jpg (from outside the web srvr docs dir) in a page with other html content?

Nov 27th, 2008 05:02
healthy man, dman, ha mo, Articles Hosting, Jonathan Sharp, Barry Prentiss,

Have a PHP script print out a header(); call with the correct image 
header (gif, jpg etc), and then do a read("path/to/file.jpg"); 
Be very careful if you're passing a variable to the read function from 
user input. Such as myphpscript.php?file=bob.jpg as this would be 
considered "tainted" data and someone could possibly try 
It's best to have the path to the file stored in a database and only 
pass an ID to the script.
But going back to your origional question, read() is binary safe so 
can just print the header and spit the contents of the file to the 
browser. All your img tags on in your html would be <img 
i hope that helps: