DataRater Posted August 13, 2008 Share Posted August 13, 2008 My understanding when sending an image to an html page we need to do the following: header('Content-type: image/jpeg'); imagejpeg($image); but we can only send one header. So how do I send some text, then an image, and then some text, like this? This is text on my HTML page. <this is a place holder for the image> This is some more text. Quote Link to comment Share on other sites More sharing options...
void Posted August 13, 2008 Share Posted August 13, 2008 nohow. you got to have an html page with an <img/> tag, which src attribute should be a php script. otherwise, you can output only an image to your browser. Quote Link to comment Share on other sites More sharing options...
DataRater Posted August 13, 2008 Author Share Posted August 13, 2008 Hi Void, That's a nice idea. What should the script look like? Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted August 13, 2008 Share Posted August 13, 2008 can i ask , do you know HTML?? this is basic stuff <html> <body> texttexttext <img src="imagelink.jpg" alt="Image missing" /> //or the php way <img src="<?php echo "imagelink.jpg"; ?>" alt="Image missing" /> </body> </html> Quote Link to comment Share on other sites More sharing options...
DataRater Posted August 13, 2008 Author Share Posted August 13, 2008 Hi Blade280891, It's the PHP script which sends the image not the image name which I'm asking for. The reason is the jpg will be in the database. Maybe it's as simple as <?php $image = get_image_from_database(); header('Content-type: image/jpeg'); imagejpeg($image); ?> Thanks anyway. Does anyone know whether this is OK? Quote Link to comment Share on other sites More sharing options...
void Posted August 13, 2008 Share Posted August 13, 2008 You have to create image_output.php file with the following content: <?php $image = imagecreatefromjpeg("path/to/image.jpg"); header('Content-type: image/jpeg'); imagejpeg($image); ?> Then, in your HTML file, the image tag should look like this: <img src="image_output.php" /> Quote Link to comment Share on other sites More sharing options...
DataRater Posted August 13, 2008 Author Share Posted August 13, 2008 Hi void, That works perfectly. Thanks!!! When I right click the image and view its properties it tells me it is image_output.php That gives away the technology i.e. php, can you think of a way around that? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 13, 2008 Share Posted August 13, 2008 It'll be fine if they know the technology...you'll need some mod_rewrite stuff to make it seem like it is another file. Quote Link to comment Share on other sites More sharing options...
void Posted August 13, 2008 Share Posted August 13, 2008 Well, you could use mod rewrite functionality. This requires .htaccess file in your site directory, with the following content (and your custom paths, if the files are not located in root directory): RewriteEngine On RewriteBase / RewriteRule ^(.+)\.jpg$ /image_output.php?file=$1.jpg [L] This should redirect any requests for a jpg image to your image_output.php file. eg. www.site.com/picture01.jpg will be internally redirected to www.site.com/image_output.php?file=picture01.jpg Quote Link to comment 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.