0

I am developing a PHP website and I am having difficulty choosing the best method for storing uploaded files.

At the moment I am considering storing the image as a BLOB in the MySQL database but I have also been told that storing the file name of the image would be enough.

Charles
  • 50,943
  • 13
  • 104
  • 142
Daniel West
  • 1,808
  • 2
  • 24
  • 34
  • 1
    possible duplicate of [Storing Images in DB - Yea or Nay?](http://stackoverflow.com/questions/3748/storing-images-in-db-yea-or-nay) – Pekka Feb 17 '11 at 12:29

2 Answers2

0

There are advantages and disadvantages to both, personally i like to store the images outside of the db and reference the file using a varchar in the db.

If you want to go down the route of storing them as a blob, then this article is a nicely balanced one.

http://www.phpro.org/tutorials/Storing-Images-in-MySQL-with-PHP.html

diagonalbatman
  • 17,340
  • 3
  • 31
  • 31
0

In my opinion storing the file names only in database is fast and rich technique. you should save the files in any other directory. When you have to retrieve, your uploaded file you just need to compare it with stored name. If you are storing multiple types of files, so its always a good technique to store them in different directories. So storing the file name in database and file elsewhere is fast and good technique in my opinion

Awais Qarni
  • 17,492
  • 24
  • 75
  • 137