Originally Posted by felgall
To save an image to a database you should use SQL to read the file into the field like this:
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.
Parse error: syntax error, unexpected T_STRING in imageupload.php on line 36
echo "That's not an image.";
if ($insert = mysql_query("INSERT INTO databaseimage VALUES ('','$image_name',LOAD_FILE($file)))
echo "Problem uploading image";
Don't I need to declare the file variable?