d.shankar Posted January 21, 2008 Share Posted January 21, 2008 Hi all.. I have this image [test.png] and a php code [test.php] in my root server [www.example.com] [test.php] <?php echo "<img src='test.png'>"; ?> when i run www.example.com/test.php the image gets loaded successfully. But when i try to access it from a local or remote site it is not working. test.html in a local system or remote server <html> <body> <i m g src="http://www.example.com/test.php"> </body> </html> The above scenario doesnot work.. Can someone help me out ? Link to comment https://forums.phpfreaks.com/topic/87011-solved-tricky-question/ Share on other sites More sharing options...
vbnullchar Posted January 21, 2008 Share Posted January 21, 2008 This is not possible.. because test.php is not a valid image <img src="http://www.example.com/test.php"> insert this code in your test.php <?php header("Content-type: image/png"); $im = imagecreatefrompng("test.png"); imagepng($im); imagedestroy($im); ?> then in your HTML <html> <body> <img src="http://www.example.com/test.php"> </body> </html> Link to comment https://forums.phpfreaks.com/topic/87011-solved-tricky-question/#findComment-444945 Share on other sites More sharing options...
GingerRobot Posted January 21, 2008 Share Posted January 21, 2008 Err..why bother? There's nothing dynamic going on, so just access the png directly: <html> <body> <img src="http://www.example.com/test.png"> </body> </html> Link to comment https://forums.phpfreaks.com/topic/87011-solved-tricky-question/#findComment-444946 Share on other sites More sharing options...
vbnullchar Posted January 21, 2008 Share Posted January 21, 2008 yes i know can be done easily by pointing to the source directly... i based my answer to the scenario he states Link to comment https://forums.phpfreaks.com/topic/87011-solved-tricky-question/#findComment-444951 Share on other sites More sharing options...
GingerRobot Posted January 21, 2008 Share Posted January 21, 2008 yes i know can be done easily by pointing to the source directly... i based my answer to the scenario he states I'm aware of that, and i wasn't criticising your response. Link to comment https://forums.phpfreaks.com/topic/87011-solved-tricky-question/#findComment-444956 Share on other sites More sharing options...
vbnullchar Posted January 21, 2008 Share Posted January 21, 2008 cheers! Link to comment https://forums.phpfreaks.com/topic/87011-solved-tricky-question/#findComment-444957 Share on other sites More sharing options...
d.shankar Posted January 21, 2008 Author Share Posted January 21, 2008 No dude it does not seem to work. ??? Link to comment https://forums.phpfreaks.com/topic/87011-solved-tricky-question/#findComment-444971 Share on other sites More sharing options...
adam291086 Posted January 21, 2008 Share Posted January 21, 2008 Post your code. Add error_reporting(E_ALL); to the top of your code. Then tell us any errors Link to comment https://forums.phpfreaks.com/topic/87011-solved-tricky-question/#findComment-444974 Share on other sites More sharing options...
d.shankar Posted January 21, 2008 Author Share Posted January 21, 2008 Sure dude i will check that out. Anyway thanks vbnullchar .. do i need to include gd library for this to achieve ? Link to comment https://forums.phpfreaks.com/topic/87011-solved-tricky-question/#findComment-444976 Share on other sites More sharing options...
adam291086 Posted January 21, 2008 Share Posted January 21, 2008 why are you trying to do this anyway. LIke GingerRobot said Err..why bother? There's nothing dynamic going on, so just access the png directly: Code: <html> <body> <img src="http://www.example.com/test.png"> </body> </html> Link to comment https://forums.phpfreaks.com/topic/87011-solved-tricky-question/#findComment-444978 Share on other sites More sharing options...
d.shankar Posted January 21, 2008 Author Share Posted January 21, 2008 Actually i will pass an an id along with the php in the img src tag. If each id it will display different images. Sort of..... Link to comment https://forums.phpfreaks.com/topic/87011-solved-tricky-question/#findComment-444987 Share on other sites More sharing options...
vbnullchar Posted January 21, 2008 Share Posted January 21, 2008 Sure dude i will check that out. Anyway thanks vbnullchar .. do i need to include gd library for this to achieve ? yes you need to have gd library Link to comment https://forums.phpfreaks.com/topic/87011-solved-tricky-question/#findComment-444992 Share on other sites More sharing options...
d.shankar Posted January 21, 2008 Author Share Posted January 21, 2008 Wow gr8 dude.. you have done it. The gd library was the issue... since i use @ infront of code to avoid warnings so i was unable to trace out. Also adam was there to the rescue. Thanks vbnullchar. Link to comment https://forums.phpfreaks.com/topic/87011-solved-tricky-question/#findComment-444995 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.