8 Replies - 1441 Views - Last Post: 27 May 2003 - 10:13 AM Rate Topic: -----

#1 iamcenz  Icon User is offline

  • You wish you were my hand!
  • member icon

Reputation: 7
  • View blog
  • Posts: 2,442
  • Joined: 26-March 01

Directories

Posted 29 April 2003 - 05:05 AM

ok here is my problem, im not sure how to do it, i never did anything like this before. for my school site that im making, there is a student work section, which is pretty much, what ever student my teacher feels did a good job, he will put it up on the site so people can see what they did. and use it as examples for the other students. well i need to be able to put in a students lastname, and have a script look for a directory with that last name, if it finds it, it will add what ever i want to that dir, if it dont then it will create it then add what i want to it. so say he went to put my work on there. he would type in Cerone and then the script will look for a directory called Cerone with my work in it. if there is no directory then it will create the folder Cerone. how would this work?

Is This A Good Question/Topic? 0
  • +

Replies To: Directories

#2 klewlis  Icon User is offline

  • cur tu me vexas?

Reputation: 8
  • View blog
  • Posts: 1,723
  • Joined: 09-November 01

Re: Directories

Posted 29 April 2003 - 07:20 AM

you don't have to actually create all those different directories, as long as the information is stored in the database. there are a number of ways you could do it:

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:
file_id: 1
file_name: myfile.doc
student_first_name: Holly
student_last_name: Vipond
insert_date: 2003-04-29

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. :)
Was This Post Helpful? 0
  • +
  • -

#3 cyberscribe  Icon User is offline

  • humble.genius
  • member icon

Reputation: 10
  • View blog
  • Posts: 1,062
  • Joined: 05-May 02

Re: Directories

Posted 29 April 2003 - 01:36 PM

klewlis, on Apr 29 2003, 06:20 AM, said:

or through a similar system. :)

ah ... the possibilities.

I like:

http://forums.dreami...=ST&f=28&t=7168

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.
Was This Post Helpful? 0
  • +
  • -

#4 iamcenz  Icon User is offline

  • You wish you were my hand!
  • member icon

Reputation: 7
  • View blog
  • Posts: 2,442
  • Joined: 26-March 01

Re: Directories

Posted 29 April 2003 - 03:07 PM

yeah that would work, but see the stuff i need to display is full working websites so i need a directory with all the stuff in it. get what i mean.
Was This Post Helpful? 0
  • +
  • -

#5 klewlis  Icon User is offline

  • cur tu me vexas?

Reputation: 8
  • View blog
  • Posts: 1,723
  • Joined: 09-November 01

Re: Directories

Posted 29 April 2003 - 03:15 PM

BluntedbyNature, on Apr 29 2003, 04:07 PM, said:

yeah that would work, but see the stuff i need to display is full working websites so i need a directory with all the stuff in it. get what i mean.

oh well you didn't tell us THAT part. :P

i don't know if uploading will work for full directories...
Was This Post Helpful? 0
  • +
  • -

#6 iamcenz  Icon User is offline

  • You wish you were my hand!
  • member icon

Reputation: 7
  • View blog
  • Posts: 2,442
  • Joined: 26-March 01

Re: Directories

Posted 29 April 2003 - 03:32 PM

yeah i know, but i dont want anyone having to create anything on the accual server, i want it all to be done through the admin control panel
Was This Post Helpful? 0
  • +
  • -

#7 cyberscribe  Icon User is offline

  • humble.genius
  • member icon

Reputation: 10
  • View blog
  • Posts: 1,062
  • Joined: 05-May 02

Re: Directories

Posted 29 April 2003 - 07:16 PM

PHP has plenty of facilities for uploading files, images ... you name it. I've worked pretty extensively on news sites that produce their articles out of a purely web-based admin. At its simplest, you plop text into text fields, upload images, and provide some basic layout control. However, you could easily break from this model and instead of text fields point to whole HTML files -- PHP is pretty irreverent about what it will include().

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).
Was This Post Helpful? 0
  • +
  • -

#8 iamcenz  Icon User is offline

  • You wish you were my hand!
  • member icon

Reputation: 7
  • View blog
  • Posts: 2,442
  • Joined: 26-March 01

Re: Directories

Posted 29 April 2003 - 09:30 PM

how would i go about doing that?
Was This Post Helpful? 0
  • +
  • -

#9 pittuck  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 27-May 03

Re: Directories

Posted 27 May 2003 - 10:13 AM

how about using virtual directories and have all files stored in one real dir with $uid_$filename where uid is the userid.

so

www.school.com/bob/

goes to

www.school.com/viewfiles.php?id=[bob's id]

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 ;)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1