Need Quick Advice - File Organization Method

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
JonathanStanton
Forum Newbie
Posts: 10
Joined: Wed Jul 21, 2010 10:07 am

Need Quick Advice - File Organization Method

Post by JonathanStanton »

Hey I need feedback:

General Idea: I want a user to be able to upload a bunch of images that connect with a specific database entry.
Question: Is putting variables in the file name the best way to find them dynamically again in the future?

Example:
[text]Filename: _uniqueID_isThumb_isPrimary_Filename.EXT[/text]
So if my user uploaded 15 photos one of the photos they could be named:
[text]123_no_yes_MyPhoto.jpg or 289_yes_no_OtherPhoto.png[/text]
Where the first number is the database unique id, then it's asking is it a thumbnail, then is it the Primary Image.

Summary: So... Is putting variables in the file name the best way to find them dynamically again in the future?
eruna
Forum Newbie
Posts: 17
Joined: Mon Jun 28, 2010 2:02 pm

Re: Need Quick Advice - File Organization Method

Post by eruna »

It would be better to have a table that records the images.

In other words

Data table:
ID | TITLE
------------------
1 | Doc title

Photo table:
photo_name | data_id
------------------------------
123.jpg | 1
124.jpg | 1

Then you can make a simple database call to get the images.

E
Post Reply