468,771 Members | 1,658 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,771 developers. It's quick & easy.

readfile and images

I'm trying to replace <IMG SRC="some image"> with the usage of readfile, but
without luck. I have seen examples like this:

header ('Content-length: ' .filesize($image_file));
header ('Content-type: image/jpeg');
readfile ($image_file);

This works OK unless you have modified the header before. What I like to do
is to display the image *within* HTML codes, something like:

<HTML><HEADER>blablabla</HEADER><BODY>
<?php
echo "This is image $image_file:<BR>";
readfile ($image_file);
?>

But if I try to use the readfile as show above, I only get garbage... (as
expected). So... how can I replace a <IMG..> statement with the use of
readfile?

--
Jørn Dahl-Stamnes
http://www.dahl-stamnes.net/dahls/
Jan 24 '06 #1
1 9040
Jørn Dahl-Stamnes wrote:
I'm trying to replace <IMG SRC="some image"> with the usage of readfile,
but without luck. I have seen examples like this:

header ('Content-length: ' .filesize($image_file));
header ('Content-type: image/jpeg');
readfile ($image_file);

This works OK unless you have modified the header before. What I like to
do is to display the image *within* HTML codes, something like:

<HTML><HEADER>blablabla</HEADER><BODY>
<?php
echo "This is image $image_file:<BR>";
readfile ($image_file);
?>

But if I try to use the readfile as show above, I only get garbage... (as
expected). So... how can I replace a <IMG..> statement with the use of
readfile?


I got it... I have to use <IMG SRC=some-php-script.php?arg=filename> and
then use the code shown at the top.

--
Jørn Dahl-Stamnes
http://www.dahl-stamnes.net/dahls/
Jan 24 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Phil Powell | last post: by
15 posts views Thread by Jameson | last post: by
10 posts views Thread by eholz1 | last post: by
4 posts views Thread by dgiglio | last post: by
5 posts views Thread by cbmeeks | last post: by
4 posts views Thread by Eric Renken | last post: by
15 posts views Thread by Ketchup | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.