Reaper0167 Posted February 27, 2009 Share Posted February 27, 2009 I have a couple images in a directory on my server. Could I just use an echo statement to display them somehow? Link to comment https://forums.phpfreaks.com/topic/147105-echo-an-image-from-a-directory-on-my-hosting-server/ Share on other sites More sharing options...
unrelenting Posted February 27, 2009 Share Posted February 27, 2009 <?php echo '<img src="linktoimage.jpg>'; ?> Link to comment https://forums.phpfreaks.com/topic/147105-echo-an-image-from-a-directory-on-my-hosting-server/#findComment-772321 Share on other sites More sharing options...
Reaper0167 Posted February 27, 2009 Author Share Posted February 27, 2009 header('Content-Type: image/png'); I added this line to the top of the php page with the echo statment you showed me. But there is just a little red x. $newname="userimages/".$image_name; echo '<img src="$newname">'; There is more code,, just showing what I am trying to echo. And is it possible to include png, jpg, and gif all in one header content? Link to comment https://forums.phpfreaks.com/topic/147105-echo-an-image-from-a-directory-on-my-hosting-server/#findComment-772328 Share on other sites More sharing options...
unrelenting Posted February 27, 2009 Share Posted February 27, 2009 header('Content-Type: image/png'); I added this line to the top of the php page with the echo statment you showed me. But there is just a little red x. $newname="userimages/".$image_name; echo '<img src="$newname">'; There is more code,, just showing what I am trying to echo. And is it possible to include png, jpg, and gif all in one header content? Just echo out a complete path to see if it works. You also might need a / in front of the userimages. Link to comment https://forums.phpfreaks.com/topic/147105-echo-an-image-from-a-directory-on-my-hosting-server/#findComment-772333 Share on other sites More sharing options...
premiso Posted February 27, 2009 Share Posted February 27, 2009 FYI. echo '<img src="$newname">'; Will not work. The $newname is taken literally in single quotes. echo '<img src="' . $newname . '">'; Would work. Link to comment https://forums.phpfreaks.com/topic/147105-echo-an-image-from-a-directory-on-my-hosting-server/#findComment-772537 Share on other sites More sharing options...
Reaper0167 Posted March 2, 2009 Author Share Posted March 2, 2009 What about if I wanted to echo all the pictures from that directory? Link to comment https://forums.phpfreaks.com/topic/147105-echo-an-image-from-a-directory-on-my-hosting-server/#findComment-775102 Share on other sites More sharing options...
samshel Posted March 2, 2009 Share Posted March 2, 2009 check this link http://us.php.net/manual/en/function.readdir.php Link to comment https://forums.phpfreaks.com/topic/147105-echo-an-image-from-a-directory-on-my-hosting-server/#findComment-775104 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.