RE: [PHP-DEV] Help displaying an image stoed in a MySQL database
| From: | Chris Newbill | Date: | Fri, 07 Dec 2001 01:04:29 +0000 |
| Subject: | RE: [PHP-DEV] Help displaying an image stoed in a MySQL database | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-72815@lists.php.net to get a copy of this message | ||
Hehe I love questions like these.
This is the wrong list for these types of questions; you want
php-general@lists.php.net. This list is about developing PHP not
developing WITH PHP.
Anyways, short answer is in an HTML document when the browser comes to
an IMG tag it makes another HTTP request to the server for that file.
So what you need to do it make a file that just displays the content of
the image.
Example.
Image.php
<?php
// do DB stuff get image data then print this
header("Content-type: image/png"); // or whatever format it is can use
application/octet-stream if unsure print $image_contents;
?>
That's it...then from your html page
<img src="Image.php?id=image_id">
-Chris
-----Original Message-----
From: Christofe DuBois [mailto:admin@scahunt.com]
Sent: Thursday, December 06, 2001 5:11 PM
To: php-dev@lists.php.net
Subject: [PHP-DEV] Help displaying an image stoed in a MySQL database
I would like to store an image in a database and then allow users to
select
the image for display...
I can upload the file, and write it to the database. I base64_encode '
d it
and dropped it in a longblob field.
I then query the database, pull the encoded image out... now what...
I have tried simply saying <img src=$encoded_var> and that doesn't work
worth squat...
So basically, I have:
HTML
HTML
HTML
HTML
HTML
Image to display here
HTML
HTML
HTML
How do I get the image to pull from the database and display there in
the
middle of all the HTML?
-Chris
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net
For additional commands, e-mail: php-dev-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net