A few words of thanks would be greatly appreciated.

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

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
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 (https://ccm.net/).