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.
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
wwwdeveloper2
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.
onemadeye
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.
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