vijayshekar Posted December 31, 2008 Share Posted December 31, 2008 Hello, I am trying to embed image from php page as follows: my html page is as below -------------------------------------- <html> <head> </head> <body> <a><img src="/images/image.php"></img></a> </body> </html> The image.php page is as below -------------------------------------------- <?php header("Content-type: image/jpeg"); echo "<img src=\"logo.jpg\" border=\"0\" align=\"left\"></img>"; ?> When I open the html page I am getting broken image. Kindly help me to display the image from the php page in my html page? Thanks Vijay Quote Link to comment https://forums.phpfreaks.com/topic/138991-solved-php-page-in-img-src/ Share on other sites More sharing options...
DeanWhitehouse Posted December 31, 2008 Share Posted December 31, 2008 echo "<img src=\"logo.jpg\" border=\"0\" align=\"left\"></img>"; should be echo "logo.jpg"; Quote Link to comment https://forums.phpfreaks.com/topic/138991-solved-php-page-in-img-src/#findComment-726890 Share on other sites More sharing options...
vijayshekar Posted December 31, 2008 Author Share Posted December 31, 2008 hi, I tried this echo "logo.jpg"; still the image is broken ? Thanks Vijay Quote Link to comment https://forums.phpfreaks.com/topic/138991-solved-php-page-in-img-src/#findComment-726913 Share on other sites More sharing options...
revraz Posted December 31, 2008 Share Posted December 31, 2008 Not sure why you would echo it like that.. Anyways, what is the path to the image? Sounds like you are omitting a folder name. Quote Link to comment https://forums.phpfreaks.com/topic/138991-solved-php-page-in-img-src/#findComment-726918 Share on other sites More sharing options...
DeanWhitehouse Posted December 31, 2008 Share Posted December 31, 2008 try changing the header to header("Content-type: image/jpg"); and then echo read_file("logo.jpg"); Quote Link to comment https://forums.phpfreaks.com/topic/138991-solved-php-page-in-img-src/#findComment-726919 Share on other sites More sharing options...
vijayshekar Posted December 31, 2008 Author Share Posted December 31, 2008 Tried this I am getting : Call to undefined function read_file() The image is in same folder as of the php page. Quote Link to comment https://forums.phpfreaks.com/topic/138991-solved-php-page-in-img-src/#findComment-726923 Share on other sites More sharing options...
DeanWhitehouse Posted December 31, 2008 Share Posted December 31, 2008 Sorry my bad, should be file(); Quote Link to comment https://forums.phpfreaks.com/topic/138991-solved-php-page-in-img-src/#findComment-726936 Share on other sites More sharing options...
premiso Posted December 31, 2008 Share Posted December 31, 2008 Sorry my bad, should be file(); I think you mean file_get_contents file returns an array, which is not needed. Quote Link to comment https://forums.phpfreaks.com/topic/138991-solved-php-page-in-img-src/#findComment-726938 Share on other sites More sharing options...
DeanWhitehouse Posted December 31, 2008 Share Posted December 31, 2008 oopz, tbh ignore me i am very tired Quote Link to comment https://forums.phpfreaks.com/topic/138991-solved-php-page-in-img-src/#findComment-726939 Share on other sites More sharing options...
vijayshekar Posted December 31, 2008 Author Share Posted December 31, 2008 Hi, Its working well now, Thanks a lot for the help Regards vijay Quote Link to comment https://forums.phpfreaks.com/topic/138991-solved-php-page-in-img-src/#findComment-726955 Share on other sites More sharing options...
premiso Posted December 31, 2008 Share Posted December 31, 2008 oopz, tbh ignore me i am very tired Eh we all have our times, but you were not far off. readfile is what he was referring to, which might be a better solution, I am not sure. PS Remember to marked as "Solved" (bottom left hand corner). Quote Link to comment https://forums.phpfreaks.com/topic/138991-solved-php-page-in-img-src/#findComment-726956 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.