Hi,
Store all files in a 'secret' folder, preferably outside the www-root.
Store filename, size, type, date, whatever in your dB.
To link to a file, use something like this a
href=download.php?fileid=3MyDoc.pdf/a
Then in download.php you update your stats table with the relevant info and
then send the file to the user.
| download.php |
?php
updatemystatsdb($_GET['id']);
$filename = getfilenamefromdb($_GET['id']);
$filetype = getfiletypefromdb($_GET[id]);
$completefilepath = /your/path/here/$filename;
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
header(Content-type: application/octet-stream\nContent-Disposition:inline;
filename=\.$fileName.\\nContent-length:.(string)(filesize($completefile
path)));
$fd = fopen($filename,'r');
fpassthru($fd);
?
This is not complete and I'm not really sure about the headers, but you can
read more at http://www.php.net/manual/en/function.fpassthru.php
/Joakim
-Original Message-
From: JJ Harrison [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 03, 2002 2:05 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Simple Example of Passing on a file through a
PHP script
I want to show info when my docs are viewed though my stats
program. I have
decieded the best way would be to put the info into a DB
through php file
then output the PDF, Excel, Zip or Powerpoint file.
Only trouble is I have no Idea how to do this
--
JJ Harrison
[EMAIL PROTECTED]
www.tececo.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php