Hi,
Very new to PHP so be gentle!
I am trying to have a single page (index.php) that discovers and displays all the folders and sub-folders on my server (this bit is done) and then allow members to upload .pdf files only to whatever folder they have navigated to. So the directory structure could look like this:-
2006/subfolder1/
subfolder1a/
subfolder1b/
2006/subfolder2/
subfolder2a/
2006/subfolder3/
subfolder3a/
subfolder3b/
subfolder3c/
2007/subfolder1/
subfolder1a/
subfolder1b/
2007/subfolder2/
subfolder2a/
2007/subfolder3/
subfolder3a/
subfolder3b/
subfolder3c/
2008/subfolder1/
subfolder1a/
subfolder1b/
2008/subfolder2/
subfolder2a/
2008/subfolder3/
subfolder3a/
subfolder3b/
subfolder3c/
Therefore when a member drills down to 2008/subfolder3/subfolder3b/ he can then UPLOAD a .pdf file.
This is where I am at right now : http://www.archive.elc-eu.org
Is this even possible?
Paul
Newbie: Is this possible?
Moderator: General Moderators
-
cpetercarter
- Forum Contributor
- Posts: 474
- Joined: Sat Jul 25, 2009 2:00 am
Re: Newbie: Is this possible?
Yes, perfectly possible.
Things to think about include:
- php sets a maximum size on uploaded files. Typically the limit is 2mb. Are the documents which your users will upload ever likely to be bigger than this?
- security. You are trusting your users not to load malicious material into your server. How will you check that the uploaded files are pdfs and nothing else?
Things to think about include:
- php sets a maximum size on uploaded files. Typically the limit is 2mb. Are the documents which your users will upload ever likely to be bigger than this?
- security. You are trusting your users not to load malicious material into your server. How will you check that the uploaded files are pdfs and nothing else?
Re: Newbie: Is this possible?
Hi cpetercarter,
The PHP upload limit wont be a problem.
Security wise the folders on the domain are username and password controlled so only members will be able to upload. However I may try and include just one member as the only person to be able to upload as I have some PHP that covers this.
I have found several PHP scripts that handle uploads to a specific named directory and I've tried modifying these to take the current directory as the place to upload but I can't get that to work. The command getcwd() didn't seem to work, so I'm stuck.
Any suggestions or can you point me to a script that does this already so I can learn?
The PHP upload limit wont be a problem.
Security wise the folders on the domain are username and password controlled so only members will be able to upload. However I may try and include just one member as the only person to be able to upload as I have some PHP that covers this.
I have found several PHP scripts that handle uploads to a specific named directory and I've tried modifying these to take the current directory as the place to upload but I can't get that to work. The command getcwd() didn't seem to work, so I'm stuck.
Any suggestions or can you point me to a script that does this already so I can learn?
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Newbie: Is this possible?
Jonah,
That sounds a good idea. I suppose it wouldn't take too much effort to relocate all the files but I have no idea how to create a virtual database, let alone a real one!
Point me in the right direction and I'll see what I can do.
Paul
That sounds a good idea. I suppose it wouldn't take too much effort to relocate all the files but I have no idea how to create a virtual database, let alone a real one!
Point me in the right direction and I'll see what I can do.
Paul
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Newbie: Is this possible?
I don't mean a virtual database, just a virtual organization system, only visible to the user. For example, the user can create "folders", who's name, parent, and owner go into a database table. Then, in a separate table containing the address, name, and owner go into another table, along with the "folder" the user chooses to put it in. Here is an example of the folders database:
That segment of a table, shows a few folders owned by user # 84082 Look carefully at how their parent columns point to other folders' IDs. A folder who's parent is 0, is the top level folder.
And here is a table of the pictures:
Look carefully how the file's folder column points to folders' IDs, or the top level (0)
These to tables together give you a fake file system like this:
Have fun coding!
Edit: w3schools.org has a great php/mysql tutorial
Code: Select all
-----------------------------------
|name |parent |id |owner_user |
-----------------------------------
|my_file |0 |1 |84082 |
|subfile |1 |2 |84082 |
|my_file2|1 |3 |84082 |
|topfile |0 |4 |84082 |
-----------------------------------
And here is a table of the pictures:
Code: Select all
-------------------------------------------------------------
|name |id |folder |owner_user |file_address |
-------------------------------------------------------------
|mypdf.pdf |1 |3 |84082 |/path/to/file.pdf |
|file.pdf |2 |4 |84082 |/path/to/file.pdf |
|somepdf.pdf |3 |2 |84082 |/path/to/file.pdf |
|somefile2.pdf |3 |0 |84082 |/path/to/file.pdf |
-------------------------------------------------------------
These to tables together give you a fake file system like this:
Code: Select all
somefile2.pdf
my_file
subfile
somepdf.pdf
my_file2
mypdf.pdf
topfile
file.pdfEdit: w3schools.org has a great php/mysql tutorial