Possible Duplicate:
Storing Images in DB - Yea or Nay?
To Do or Not to Do: Store Images in a Database
I'm currently in the process of creating my friend's artist portfolio website. She asked me to create a simple system where she can upload an image and it will be displayed on the site according to the category it is in. I've stumbled upon several useful and interesting ways in which to achieve this and I've narrowed it down to the two that seem the most useful for me. Unfortunately, I do not know which one would be a better choice.
Option A: http://www.phpriot.com/articles/images-in-mysql
This method uses a very controversial way of storing images in a mySQL table using the
blob
datatype. I've read that it isn't recommended by many PHP programmers, however, it does seem like it can fit my needs perfectly. From what I understand it is fairly simple and easy:
- Upload Image to DB
- Display Image from DB according to category chosen.
Option B: http://webdeveloper.com/forum/showthread.php?t=101466
This method only shows how to upload an image to a directory using PHP. I figured once that is done I could make a simple list of all the images in that directory and put it into an array. Afterwards loop through the array and display those items in
<img>
tags.
So, you see, I am still learning how to work with PHP and mySQL and this website is great motivation to learn. However, I'm unsure of which method to use, or if there is a single method most web developers use?
Questions to Think About // TL;DR
- What is the best method for uploading images that most of you use?
- Would you consider using mySQL 'blob' datatype?
- If uploading the image to a file directory is best, how would I display the images--using an array, placing the list of images in a DB, or something entirely different (because I'm a noob and don't know any better)
Thanks in advance for any replies!