you could also try this: header("Content-Type: application/octet-stream"); header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=$name"); header("Content-Transfer-Encoding: text");
or this header( "Content-type: application/octet-stream" ); header( "Content-Disposition: attachment; filename=$skeleton_name.skl" ); header( "Content-Length: $filesize" ); echo $file_contents; or this $size=filesize("urfile"); header("Content-Type: application/octet-stream"); header("Content-Length: $size"); header("Content-Disposition: attachment; filename=urfile_name.mp3"); header("Content-Transfer-Encoding: binary"); $fh = fopen("urfile_name", "r"); fpassthru($fh); they all work for me =) I know I should pick one and stay with it but I get bored =) -----Original Message----- From: George Pitcher [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 19, 2003 10:33 AM To: Matt Babineau; [EMAIL PROTECTED] Subject: RE: [PHP-WIN] Force a user to download a text file from a link Matt, You should NEVER force a download on anyone. How do they know it isn't carrying a virus. What you should do is to send the headers that prompt a dialog box for Save or Open (I'm sure you've seen this). I'm not sure which headers you use for csv or txt files but I do this with PDFs all the time. <?php $fpd = "E:\\Pdf\\" . $fp . ".pdf"; $len = filesize($fpd); header("Content-Type: application/pdf"); header("Content-Disposition: inline; filename=$fpd"); header("Content-Title: $fpd"); header("Content-Length: $len"); readfile($fpd); ?> I suspect that you just need to change pdf to text in the Content-Type line. Using the above script will always save the file as (scriptname.pdf) so I've been a bit creative and when my user is heading towards a document, an appropriately named script containing the above script is created on the fly and called to handle the download. It is then deleted when they confirm downloading. The rest of my site uses Lasso so there's no point showing how those parts work. HTH George > -----Original Message----- > From: Matt Babineau [mailto:[EMAIL PROTECTED]] > Sent: 19 February 2003 4:24 pm > To: [EMAIL PROTECTED] > Subject: [PHP-WIN] Force a user to download a text file from a link > > > How can I force a download of a TXT file from a Link? Or an Excel CSV > file? using PHP of course too. I am running PHP 4.3 on W2K. Are there > any tutorials for this? > > Thx- > > Matt > -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php