Page 1 of 1

File downloads

Posted: Sun Sep 19, 2004 11:47 am
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?

Posted: Sun Sep 19, 2004 11:53 am
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.

Posted: Sun Sep 19, 2004 1:15 pm
by Stelios
thanks for your reply! Is there any web site that I can get an example from?

Posted: Sun Sep 19, 2004 1:20 pm
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..

Posted: Sun Sep 19, 2004 6:29 pm
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!

Posted: Sun Sep 19, 2004 6:38 pm
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..

Posted: Sun Sep 19, 2004 7:42 pm
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. :)