
June 19th, 2000, 04:31 AM
|
 |
Full Access
|
|
Join Date: Jun 2000
Location: London, UK
Posts: 2,019
Time spent in forums: 3 sec
Reputation Power: 15
|
|
|
From what I know about mySQL it is possible to store an image in a database under the BLOB (Binary Large OBject) datetype. However, the maximum size of your picture is limited to 65535 bytes. In order to get your picture into your database I presume you'd do something like this:
<form action=POST enctype=multipart/form-data method=add.php3>
<input type=file name=file>
</form>
---ADD.PHP3---
<?
// Assume already connected to database
insert into table values (
$file
);
?>
That's how to get it in, assuming you have a table called test with one column that is a BLOB datatype: you'll have to use PHP or similar to view the image on a web page, which means that the image tag is going to be something like this:
<img src="recall.php3?name=foo">
which is a bit wierd!
You also might run into problems here if your web host has set a maximum amount of table space that you can use. Whilst 10MB might seem ample for a database containing text, when you start to add pictures it will be used up very quickly! This is another reason why people use the image-copying way of doing it. Personally, when I'm adding records to a database, I'll use PHP to generate a random number, then that random number becomes the image name as well so there's no possibility of the file overwriting another on the server.
------------------------
Alex Greg
(http://www.alex-greg.co.uk)
[This message has been edited by alexgreg (edited June 19, 2000).]
|