|
Posted by J.O. Aho on 01/12/06 09:05
ryan wrote:
> great. thank you!
>
> with this method, what is the set up? meaning what passes it the name
> of the file to look for?
> is the situation something like this. user logs in, sees links for
> these documents, they would click a link and that should be set up in
> what manner?
There are three ways to list the files (as I can think of after been up most
of the night), what to use depends on your needs.
1. filenames are stored in a database, the names are then fetched by need
2. filenames are hardcoded into a file or uses a configuration file that has
all the filenames
3. a script makes a check of what files can be found in the directory and
lists them.
IMHO option 1 is the best, as it gives you more possibilities, like give the
files different categories, you can store descriptions of the file and even
store how many times a file has been downloaded (or at least how many times
there has been an attempt to download it).
Regardless which method you use, you will need to have the following kind of
anchor for each file you want to allow people to download
<a href="download.php?f=pegasos2_faq.pdf">Pegasos 2 FAQ</a>
<a href="download.php?f=lvm_howto.pdf">Logical Volume Management HOWTO</a>
I do suggest that you replace all spaces in filenames with _, this makes
things a lot easier.
This example would have two downloadable links, that calls the download.php
script, which checks if the person is logged in and allows a download if the
file is in the /home/username/pdf direcotry.
The '?' after download.php tells that there are arguments that are sent to the
script, 'f' is the "variable" name and the 'pegasos2_faq.pdf' is the value.
This value will be stored in a global array called $_REQUEST, and we will get
the value with $_REQUEST['f']
I hope this explains it well enough, if not, just drop another post with
questions.
//Aho
[Back to original message]
|