Link to home
Start Free TrialLog in
Avatar of aindi
aindi

asked on

Best way to store images in a blog/cms system

I am in the process of developing a blog system. Users will be able to upload multiple images to a particular blog entry.  I am going to store the images in the file system.

My question is where to store the uploaded images? I have found some answers like below.

1. create folder for every blog with ID and store the images related to that blog.
   
   Images for Blog ID 1000000001 would be stored in folder: 10/00/00/00/01/abc.jpg

2. create folders by year and month (from blog entry creation date).
 
   Images for 2011/Mar will be store in folder : /images/blog/2011/03/abc.jpg.

3. create folders by user id (the user who uploads the images).

    Images for User ID 1000000001 would be stored in folder: 10/00/00/00/01/abc.jpg

I need to know which one is the efficient method.

I am planning to use CKEditor with CKFinder to edit and upload images. When the user uploads the images using CKFinder the images will be uploaded in the filesystem and <img> tag will be placed in the textarea. In this scenario How to store the uploaded images path to the db? Because later If I want to delete the blog , I should be able to delete all the images related to that blog.

Hope I explain my problem clearly.
ASKER CERTIFIED SOLUTION
Avatar of wwwdeveloper2
wwwdeveloper2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aindi
aindi

ASKER

Hi wwwdeveloper2!

Thanks for your comment.

I am using php 5 with mysql on linux.

Still I am not clear about which way I should use to store the images either by creating a directory for every blog id or by year and month or by user id or a common directory for all blogs. I need to know the pros and cons of these and the best one to use. After that I will raise other questions related to this.

Thanks

Ok, well that is all I have for now.  I gave what I would do.  The point value of this question isn't worth posting pros and cons for every single situation on how this can be accomplished.  It would be like writing a book.

Good luck.  Hopefully somebody else will have time.

I think you could refer to WORDPRESS for how they store images (num#2 from your post) and I think it's good to separate the uploaded images by year and month.

Regards...
SOLUTION
Avatar of Alan Henderson
Alan Henderson
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You should use method 1 because this will be easier for you
if you want to delete all images of one particulaer blog when deleting the associate blog.

method 2 will be harder to find which image goes with wich blog

method 3 if a user have more than one blog and you want to delete only one blog with associate images this will be also hard to find out.