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? Quote 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>'; ?> Quote 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? Quote 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. Quote 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. Quote 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? Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.