Coreyp_1
07-27-2003, 12:14 PM
Hello, All!
I'm new to PHP, and have a question about downloading files through PHP.
My situation is this: I have a collection of PDF files. I have a database for keeping track of the files, their authors, editors, etc.., and I have a working membership system.
I want to be able to allow members to download the PDF files. Since I use a logical naming convention to name my files (so *I* can keep track of them), I want to keep users from simply figuring out the convention and downloading the files on their own without being logged in as a member.
To remedy this, I encrypted the file names on the server, so that no logical method can be used to infer the file names, and short-circuit my system.
I use a file (download.php) which checks the member status, and, if registered, outputs the PDF headers, and then performs a readfile() from the encrypted file name.
I like this because:
(1.) Even though the file name on the server is encrytped, I can still suggest the correct file name using
header("Content-Disposition: attachment; filename=whatever_i_want_it_to_be.pdf"));
(2.) I can fully control whether or not the PDF will be downloaded, because there is no hope of the user being able to figure out the file name on the server (encrypted).
I was happy with this system until I tried to have two downloads going at once, and it didn't work!
In fact, my site does not respond at all until the download is finished, which means if the PDF is 5 megs, then the user cannot browse other parts of my site in the background while that loads, but has to sit there and wait. Worse yet, I'm afraid that if one user is downloading a file, then my site will be temporarily unavailable to ANYONE else (on the internet) until the download is finished and the script is over (although I cannot test this, seeing as I only have one computer and one internet connection.
I'm aware that I could do a simple redirect using
header("Location:encrypted_file_name.PDF");
but this will not allow me to suggest what the real file name should be (as far as I know);
All of that to get to this: Is there a way to allow multiple downloads using PHP as an intermediary?
This is my first PHP project (aside from simple includes on HTML pages).
Thanks for the help!
I'm new to PHP, and have a question about downloading files through PHP.
My situation is this: I have a collection of PDF files. I have a database for keeping track of the files, their authors, editors, etc.., and I have a working membership system.
I want to be able to allow members to download the PDF files. Since I use a logical naming convention to name my files (so *I* can keep track of them), I want to keep users from simply figuring out the convention and downloading the files on their own without being logged in as a member.
To remedy this, I encrypted the file names on the server, so that no logical method can be used to infer the file names, and short-circuit my system.
I use a file (download.php) which checks the member status, and, if registered, outputs the PDF headers, and then performs a readfile() from the encrypted file name.
I like this because:
(1.) Even though the file name on the server is encrytped, I can still suggest the correct file name using
header("Content-Disposition: attachment; filename=whatever_i_want_it_to_be.pdf"));
(2.) I can fully control whether or not the PDF will be downloaded, because there is no hope of the user being able to figure out the file name on the server (encrypted).
I was happy with this system until I tried to have two downloads going at once, and it didn't work!
In fact, my site does not respond at all until the download is finished, which means if the PDF is 5 megs, then the user cannot browse other parts of my site in the background while that loads, but has to sit there and wait. Worse yet, I'm afraid that if one user is downloading a file, then my site will be temporarily unavailable to ANYONE else (on the internet) until the download is finished and the script is over (although I cannot test this, seeing as I only have one computer and one internet connection.
I'm aware that I could do a simple redirect using
header("Location:encrypted_file_name.PDF");
but this will not allow me to suggest what the real file name should be (as far as I know);
All of that to get to this: Is there a way to allow multiple downloads using PHP as an intermediary?
This is my first PHP project (aside from simple includes on HTML pages).
Thanks for the help!