-1

I want to know If there is any way to load an image into a table like:

CREATE TABLE MyTable( id INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY, images BLOB NOT NULL,

INSERT INTO MyTable (image) VALUES(LOAD_FILE('/tmp/your_image.png'));

But also if i can add an url instead of the path to my image:

INSERT INTO MyTable (image) VALUES(LOAD_FILE('https://imgur.com/gallery/6rKiG'));
  • Please read about [how to ask good questions](//stackoverflow.com/help/how-to-ask) and try to edit your question. With high quality questions you will receive better answers faster. Thanks! – Tobi Nary Mar 01 '16 at 16:45

1 Answers1

0

You can try this:

INSERT INTO x(id,pic) VALUES(1,LOAD_FILE('C:/Desktop/images/test.jpg'));

And then with PHP (for example) you can read and print

/*
Read from database
...
... */
echo '<img src="data:image/jpeg;base64,'.base64_encode( $result['pic'] ).'"/>';

For reference LOAD_FILE

Lorenzo Belfanti
  • 1,205
  • 3
  • 25
  • 51