1

Possible Duplicate:
Storing Images in DB - Yea or Nay?

I'm building a website as a learning exercise in PHP and MySql for use for sharing pictures between me and my friends. The general ideas is we each have a login, upload our photos to albums and can send links to the albums to each other. Yes, could use something else - but the point is this is just something I'm doing to learn. All going well but wondering, when uploading the images, is it better to do so to the file system or database? Not sure what best practice is? Any pointers would be helpful! TIA.

Community
  • 1
  • 1

2 Answers2

3

Store a path to the image in the database /path/to/image.jpg and then store that file on your file system somewhere.

It's a bad practice to store images in a database, far better to keep it just text.

mikevoermans
  • 3,967
  • 22
  • 27
  • Or just use the same path for your images and name the file [image_id].jpg where image_id is a unique identifier. – GWW Jan 16 '12 at 20:59
0

Best practice changes based on requirements. If your requirement is simply to learn from the experience, then the answer is easy -- do it both ways. :)

Alex Howansky
  • 50,515
  • 8
  • 78
  • 98