I am using PHP to load images into the following table:
CREATE TABLE image_data (
Image_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
Type TINYINT UNSIGNED default '1' NOT NULL,
ContentType VARCHAR(255) NOT NULL,
Image LONGBLOB NOT NULL,
Size INT UNSIGNED NOT NULL,
Width INT UNSIGNED NOT NULL,
Height INT UNSIGNED NOT NULL,
PRIMARY KEY (Image_ID)
) ENGINE=MYISAM DEFAULT CHARSET=latin1;
Once I read an image file using:
$file_size = filesize($file);
$imageFile = addslashes(fread(fopen($file, "r"), $file_size));
I store it in the database using:
UPDATE image_data SET Type = $type, Image = '{$imageFile}', Size = '{$file_size}' WHERE Image_ID = $imageDataID;
This seems to work fine for many images, but I get the following error when I try it on a certain file:
"MySQL server has gone away".
When I don't set the Image attribute in the statement, everything is fine. It seems like either the Image attribute value for this file is corrupted, or maybe it is too big to transfer...
The file's size is 1,224KB.
Does anyone know what could be wrong?
thanks in advance