Insert an Image in a MySQL database

April 2018


I am creating a website to purchase books online using PHP and MySQL, and my problem is:
How to store images of books in a database knowing that the photo of each book should appear in the consultation of books offered on the site. I know that to store images in a database slows down query execution... What is the method better than the latter? Thank you in advance.


I think the easiest way is to store the picture link in the database and not the image itself.
  • Make a column for example img_src and paste the link to your photo.
  • Example: C: \ www \ site \ images \ myphoto.jpeg
  • When generating page views, make:
    • SELECT * FROM MyTable WHERE ID = 1
  • You will have all the information, simply paste it in a table.

Solved by Skeletyon
Published by aakai1056. Latest update on September 14, 2011 at 01:12 PM by aakai1056.
This document, titled "Insert an Image in a MySQL database," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (
Store the value of a textbox
WampServer- localhost issue