8 Replies - 1588 Views - Last Post: 27 May 2003 - 10:13 AM
Posted 29 April 2003 - 05:05 AM
Replies To: Directories
Posted 29 April 2003 - 07:20 AM
1) actually create a directory for each student's name
2) put them all in one directory and let the db know which file is associated with a given name
3) break the files up some other way (say by the first letter of the last name) if you have too many to put in one directory.
the point is that you let the database do all the sorting. so let's say i upload file myfile.doc and put it in the V directory (for my last name). then my database record might look like this:
and whatever else you want to track. then when they want to search, you just search the database instead of the actual files. this gives you a lot more flexibility for searching, sorting, and listing. does that make sense?
if you think you'll have a LOT of files and don't want to worry about duplicate names, etc, you can provide another layer of abstraction by simply saving all the files in ordered names (like 00001.doc, 00002.doc, etc) and associate those in the db, by id:
file_id: 1 (so the *actual* filename is 00001)
file_name: myfile.doc (the *perceived* filename)
or through a similar system. :)
Posted 29 April 2003 - 01:36 PM
klewlis, on Apr 29 2003, 06:20 AM, said:
ah ... the possibilities.
this approach to create a layer of abstraction using directories.
However, an SQL database is going to be faster on lookups than the filesystem. Unless you have some kind of flash ROM drive I don't know about.
Posted 29 April 2003 - 03:15 PM
BluntedbyNature, on Apr 29 2003, 04:07 PM, said:
oh well you didn't tell us THAT part. :P
i don't know if uploading will work for full directories...
Posted 29 April 2003 - 07:16 PM
If you're worried about having to upload a lot of files in a directory, consider GZIPing them. I believe there's even a plugin that will allow PHP to read GZIP'd archives and display their contents. So, you could write a display engine that simply un-zips and includes the appropriate files based on your key (ID, student name, whatever).
Posted 27 May 2003 - 10:13 AM
Or have i got the wrong end of the stick
Post if you want more info, i will have to check my method before i post it too