View Single Post
Old 01-07-2013, 02:14 AM   PM User | #6
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,532
Thanks: 0
Thanked 503 Times in 494 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
To save an image to a database you should use SQL to read the file into the field like this:

Code:
INSERT INTO databaseimage VALUES ('','$image_name',LOAD_FILE($file))
That way you do away with the PHP code to try to convert it from a file into data that can be inserted into the database. You can also use the SQL DUMPFILE command to write the field from the database directly into a file again. The file in the database should have all of the headers etc included with it (as happens when you use LOAD_FILE) as otherwise the image can be easily broken.

I assume the autoincrement field is there to allow for multiple images with the same name as otherwise the image name could be used as the primary key.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote