Re: file downloading

From: Date: Thu, 19 Jun 2003 19:07:17 +0000
Subject: Re: file downloading
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-152219@lists.php.net to get a copy of this message
create a script getFile.php when this is called first update the database, then using header you can stipulate what type of document it is and it will prompt for download for example for a Word document <?php #Query here to update the database #then after successful output the headers that will prompt for download # $data is the raw data of the document either from an fopen or from the database Header( "Content-type: application/msword"); Header('Content-Length: ' . strlen($data)); Header('Content-Disposition: attachment; filename="document.doc"'); echo $data; ?> Notes: make sure you don't echo anything before the headers even suppress any errors that may come from query you can call the script through the web page as follows <a href ='getFile.php'> Click here to download the document </a> "Mark Roberts" <Mark.Roberts@Williams.com> wrote in message news:57485DA54254874FA9BED61280213740023D3E84@wmstutem04.williams.com... I need to provide a way for users to download data files from a web site. I know that I could have then right click and save-as, however, I need to record this action in a database. If they just right click, I don't have any way to trigger the script to record the transaction. Does some one have a good way to do this, or at least give me some ideas? Thanks. Mark Roberts Sr. Systems Analyst

« previous php.general (#152219) next »