I'm working on a CMS for my blog and portfolio and was wondering if anyone could please help me out. I'm just wondering what is the best approach to adding images to my blog and portfolio tables. Should I put all the images in a separate table and use a separate form in my CMS just for images or should I just add a couple fields for image details to the tables I already have for my blog and portfolio and insert them with the same form I'm using for inserting the blogs details and content.
Asked
Active
Viewed 258 times
2 Answers
0
Well, for an easy CMS I wouldn't store any image details in the database.
I'd rather put them in a folder, and get whatever details on the fly.

Your Common Sense
- 156,878
- 40
- 214
- 345
-
Yeah I plan on storing the images in a folder and then the url and file name and the image alt into the database and I'm just wondering should I store the images details with a separate form and table or should I just store the image details with the same form I'm using for inserting my blog content with and add the image details to my blog table? – i092173 Feb 10 '13 at 19:01
0
Not everyone thinks the same about this. There are several things you can do, here are some that I know:
- You can put the location (preferably semi-randomized filenames, for security reasons) in a table field.
- You can put the image itself as a
blob
-data in the table field. - You can save your uploads as
sha1(fileid)
.extention
and retrieve the id of the upload.
I guess its better to create a seperate table for media/uploads as it will be the central place. It would also make things easier to find.
Take all of the above, plus the things you have found around the internet into consideration. There's no simple answer to your question, as this differs from system to system.

jeroenvisser101
- 856
- 10
- 23
-
Yeah I plan on doing number 1. but should I use a separate form for my image uploads or just add the into my current form and insert into the table I'm using for my blog content – i092173 Feb 10 '13 at 19:13
-
Depends on what you want. I would just add a input to your current form, adding some code to the target page, and voila! – jeroenvisser101 Feb 10 '13 at 19:14
-
1