|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I've noticed a number of questions on the board about storing images in databases. My question is this (hopefully it's a simple one)
Can the actual jpg/gif image be stored as data in the database... or is it just a path to where the image is stored? If it can be stored as actual data.... how? |
|
#2
|
||||
|
||||
|
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).] |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > Stupid image/database question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|