Greetings,
I need to create a script to let registered users to download files from
a non-public folder.
The files name, type, and size are stored in a MySQL Database. The user
need to click on a link, and a PHP script should handle the download of
the file.
Here is how I organized it:
The script gets the ID from the $_GET array, retrieve the name, type,
and size from the database, and then it sends the following:
[CODE]
header("Content-Type: $type");
header("Content-Length: " . filesize($fileNameWithAbsolutePath));
header("Content-Transfer-Encoding: binary");
header("Expires: 0");
header("Cache-Control: no-cache, must-revalidate");
header("Cache-Control: private");
header("Content-Disposition: attachment; filename=\"$fileName\"");
readfile($fileNameWithAbsolutePath) or die("File not found.");
[/CODE]
This script needs to work with any file type. I checked it and it works
fine with PDF, TXT, and MP3 for example, but not with ODT, DOC, or JPG
which are corrupted and won't even open. Those are the only files I
tried so far.
I should add that the connection to the web page is encrypted through
SSL. The server (Fedora 9) runs Apache 2.2.9, PHP Version 5.2.6, and
MySQL version 5.0.51a.
I cannot find any solution to this problem, and I hope that anyone here
can help me.
Thank you.
Stefano
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php