File downloads

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
User avatar
Stelios
Forum Commoner
Posts: 71
Joined: Fri Feb 06, 2004 6:25 am
Location: Surrey/UK

File downloads

Post by Stelios »

I am trying to create a DB in mysql that is going to store files for download by the the user. somebody told me that I have to isert the files in the db and the then link them dynamically. Is there anybody who can explain this in a simpler way?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

as we've talked about this before, here's the short of it: we've pretty much agreed, storing files in the database is not the greatest idea. Instead store them in the filesystem in a folder that's protected by a htaccess or better yet, isn't accessible to a web user (outside the document root) ...

Store only the linking information (filename, full path to actual file for the script to read the file) in the database.
User avatar
Stelios
Forum Commoner
Posts: 71
Joined: Fri Feb 06, 2004 6:25 am
Location: Surrey/UK

Post by Stelios »

thanks for your reply! Is there any web site that I can get an example from?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'm not sure what you want an example of...

the thread is around here somewhere, although I haven't been able to find it in a while.. (might have gotten lost in the database crash)

as for a site that uses these techniques, BattleCorps has (link in my sig), the fiction section is powered like it. Everywhere else, pretty much requires you being a member.. so not too sure you'll get a great sense of how it's done..
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Feyd,

Can you give me a short version of why storing files in the db is bad. Not that I do that, I'm just interested.

Thanks!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it mostly stems from having to do extra work to get at the data.. for the server, and the programmer. there are other things like: what's the use of storing static content in the database?

For me, databases haven't seemed really engineered to handle binary data (en masse) like this.. I'm fairly sure the bigger ones, Oracle and Sybase and whatnot have better controls for this.. but the ones most of us use, don't have the feeling like they were designed to handle binary data very easily..
User avatar
dethron
Forum Contributor
Posts: 370
Joined: Sat Apr 27, 2002 11:39 am
Location: Istanbul

Post by dethron »

It is a burden to store static files in db. We have filesystem to do it :)
And the storage capacity of HD is greater than the capacity of DB.
In my opinion, if we do not need the abilities that come with using db, simply don't use it. :)
Post Reply