temjin Posted January 24, 2008 Share Posted January 24, 2008 I know this has been asked before. I looked it up on the site but even copying the code and pasting it is not working. Here is my code, ALL OF IT. I just cant seem to load an image, no matter how simple I make the code: <html> <?php header('Content-Type: image/jpeg'); $image = open_image($image); if ($image === false) { die ('Unable to open image'); } // ... Do some manipulation here ... // Send header // Display image function open_image ($file) { $im = @imagecreatefromjpeg('Spiderman_3.jpg'); if ($im === false) { die ('Unable to open image'); } echo 'Opened image'; } ?> <head> <title>Untitled Document</title> </head> <body> <?php imagejpeg($image); ?> </body> </html> Here is the error I got: Warning: Cannot modify header information - headers already sent by (output started at /.reducto/web/apps/vtfileman/dxs129/phptest.php:2) in /.reducto/web/apps/vtfileman/dxs129/phptest.php on line 3 Opened image Warning: imagejpeg(): supplied argument is not a valid Image resource in /.reducto/web/apps/vtfileman/dxs129/phptest.php on line 23 The code is so simple. I really posted EVERYTHING in the page. Can someone please tell me what Im doing wrong? Oh, I have the page on a server provided by my school. Ive never had a problem with PHP pages through them before. SOME PLEASE HELP! Quote Link to comment https://forums.phpfreaks.com/topic/87604-load-image-in-html-filei-know-its-been-asked-before/ Share on other sites More sharing options...
beansandsausages Posted January 24, 2008 Share Posted January 24, 2008 EDIT : sorry wrong bored. Quote Link to comment https://forums.phpfreaks.com/topic/87604-load-image-in-html-filei-know-its-been-asked-before/#findComment-448060 Share on other sites More sharing options...
The Little Guy Posted January 24, 2008 Share Posted January 24, 2008 <?php header('Content-Type: image/jpeg'); $image = open_image($image); if ($image === false) { die ('Unable to open image'); } // ... Do some manipulation here ... // Send header // Display image function open_image ($file) { $im = @imagecreatefromjpeg('Spiderman_3.jpg'); if ($im === false) { die ('Unable to open image'); } echo 'Opened image'; } ?> <html> <head> <title>Untitled Document</title> </head> <body> <?php imagejpeg($image); ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/87604-load-image-in-html-filei-know-its-been-asked-before/#findComment-448061 Share on other sites More sharing options...
temjin Posted January 24, 2008 Author Share Posted January 24, 2008 hmmm now it just says: http://filer.case.edu/dxs129/phptest4.php Is there a problem with my server? Quote Link to comment https://forums.phpfreaks.com/topic/87604-load-image-in-html-filei-know-its-been-asked-before/#findComment-448077 Share on other sites More sharing options...
PFMaBiSmAd Posted January 24, 2008 Share Posted January 24, 2008 You cannot output image date in the middle (start or end) of a html web page. Each image on a web page requires an <img src="url" alt=""> tag - http://w3schools.com/html/html_images.asp To output an image using php, the url in src="url" is the url of your php script, something like <img src="image.php" alt=""> Quote Link to comment https://forums.phpfreaks.com/topic/87604-load-image-in-html-filei-know-its-been-asked-before/#findComment-448156 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.