RE: [PHP] Simple Example of Passing on a file through a PHP scrip t

From: Date: Wed, 03 Jul 2002 13:12:22 +0000
Subject: RE: [PHP] Simple Example of Passing on a file through a PHP scrip t
Groups: php.general 
Request: Send a blank email to php-general+get-105165@lists.php.net to get a copy of this message
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=3">MyDoc.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:webmaster@tececo.com] > Sent: Wednesday, July 03, 2002 2:05 PM > To: php-general@lists.php.net > 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 > webmaster@tececo.com > www.tececo.com > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#105165) next »