2

I have a table with

create table pictures(
    pic_ID int,
    picture blob,
    primary key (pic_ID)
);

I use INSERT INTO pictures VALUES (1, load_file('/home/hai/Pictures/icon.jpeg'));
and then select * from pictures; displays this

result

Why it has NULL in my picture column ?

  • 1
    If you are using input type='file' for uploading an image then you must have enctype='multipart/form-data' attribute in form tag. eg-
    – Abhishek Kamal Apr 15 '19 at 08:55

1 Answers1

6

Standard MySQL in Ubuntu runs with secure_file_priv enabled, which means that you can't just load from (and write to) any file on your system: the file must reside in a particular directory. You can verify that this is the case using this command:

SHOW VARIABLES LIKE "secure_file_priv"

You can either turn this setting off (which is a security exposure) or find a way to move your pictures into this directory.

Jos
  • 29,224