Picture Including

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Picture Including

Post by tecktalkcm0391 »

Could somone refresh my memory can you just go like this:

Code: Select all

include("\home\images\picture1.jpg");
or do you have to do something eles to show a picture from non internet visiable folder?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

You would have a php script supply the image using file_get_contents() and readfile(), and include it via

Code: Select all

<img src="http://domain.com/image.php?id=image4">
brendandonhue
Forum Commoner
Posts: 71
Joined: Mon Sep 25, 2006 3:21 pm

Post by brendandonhue »

Also you need to send a Content-type with header() before your include().
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Content-type and content-length are both needed. Do not ever use include() for binary files unless you know EXACTLY what you're doing. Any PHP code contained within will be run.
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

How could I take a picture file than and make it displayed from a non internet visiable folder?
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

Wow Jcart I totally skipped over you post. It helped a lot THANKS!
Post Reply