Ask a question »

Insert an Image in a MySQL database

December 2015

Insert an Image in a MySQL database


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
For unlimited offline reading, you can download this article for free in PDF format:

See also

In the same category

Published by aakai1056.
This document entitled « Insert an Image in a MySQL database » from CCM ( is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.