How can I store and retrieve images from a MySQL database using PHP?

后端 未结 6 2187
心在旅途
心在旅途 2020-11-22 05:21

How can I insert an image in MySQL and then retrieve it using PHP?

I have limited experience in either area, and I could use a little code to get me started in figur

6条回答
  •  无人及你
    2020-11-22 05:39

    My opinion is, Instead of storing images directly to the database, It is recommended to store the image location in the database. As we compare both options, Storing images in the database is safe for security purpose. Disadvantage are

    1. If database is corrupted, no way to retrieve.

    2. Retrieving image files from db is slow when compare to other option.

    On the other hand, storing image file location in db will have following advantages.

    1. It is easy to retrieve.

    2. If more than one images are stored, we can easily retrieve image information.

提交回复
热议问题