Jump to content

[SOLVED] adding an image in the middle of some text on an HTML form


DataRater

Recommended Posts

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.

 

 

 

 

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>

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?

 

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" />

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

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.