PHP: Grab an image from a stream (in an img tag) but if it's not there, i don't want the img tag wri
Posted
by Gary Willoughby
on Stack Overflow
See other posts from Stack Overflow
or by Gary Willoughby
Published on 2010-05-19T10:32:32Z
Indexed on
2010/05/19
10:40 UTC
Read the original article
Hit count: 261
I currently have code like this in a web based file called 'view_file.php' to grab an image from an internal network.
<img src="put_file.php?type=<?=$TN_TYPE;?>&path=<?=$TN_PATH;?>&filename=<?=$TN_FILENAME;?>" />
The 'put_file.php' script allows access to an internal server that we don't want to expose to the internet. This script checks to see if an image is available and if it is, sends an image header and then uses readfile()
to stream the image to the 'view_file.php' page.
The problem is if there isn't an image available, instead of streaming a temporary 'spacer.gif' i want to not have the img tag written at all.
Any Ideas how to do this? I'm thinking maybe move the img tag into the 'put_file.php' script, but how to mix strings and steams?
© Stack Overflow or respective owner