I want to save images in a mysql database. I read one option:
INSERT INTO tblname(ID,IMAGE) VALUES(1,LOAD_FILE('C:/path.jpg'));
This option save a null value in the field, when realise select rows of the table, the result is a null value and also don't work in a sql php query.
Any idea?
you can save as LONGBLOB datatype in mysql, to store it binary in the database.
CREATE TABLE pictures (
'id' INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
'image' LONGBLOB NOT NULL,
PRIMARY KEY ('id')
)
then
$sql = "INSERT INTO pictures(image)
VALUES('".file_get_contents($tmp_image)."')";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.