Online Shopping : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

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

Entry

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 
myphpscript.php?file=/etc/passwd 
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 
you 
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 
src="myphpscript.php?file=image2">
=====
bugs.php.net/37467
i hope that helps:
http://www.healthdothealth.com
http://www.healthxhealth.com
http://www.mesotheliomainmesothelioma.com
http://www.healthfirewall.com
http://www.flathealth.com
http://www.healthbodyguard.com