Saving uploaded content

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Saving uploaded content

Post by onion2k »

This topic here made me realise something: viewtopic.php?t=64458

Where do you save user generated content to? In the topic the poster is saving images to images/news. That's something I would never do. The images directory on a site I write is specifically for static images that I've created as part of the site design. I gather all the user content together in a single place away from the things I control, usually in a /content/ directory or subdomain, and organised by type or section, eg /content/pdf/ or /content/news/. The reason I do this is simple: it means I can take a copy of the website content and neatly slot it into a new version, or save it as a back up, or such incredibly quickly without having to work out what's user content and what's my content.

But is that the best approach? What other solutions have people come up with?
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

Save it to a specialised directory - mainly for your reasons too - but also so I can serve it from a separate subdomain (browser can parallel request) and also usually to keep it beneath the webroot where it can't be remotely called directly without going through a request gateway in the application code.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Mostly all I've dealt with regarding uploads is images.

In which case I have two directories

/uploads/
/thumbs/

I give each user their own directory (which is their user id in the users table)

/uploads/1/somefile.jpg
/thumbs/1/somefile.jpg
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply