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.

 

 

 

 

Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.