Re: More on: how to send a file to the user's browser?

From: Date: Tue, 19 Mar 2002 01:01:41 +0000
Subject: Re: More on: how to send a file to the user's browser?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-89063@lists.php.net to get a copy of this message
Use Header() ... I remember it's something like : header ("Location: http://yoursite.ext/yourfile.ext"); Am I wrong ??? ----- Original Message ----- From: Carlos Fernando Scheidecker Antunes <nando@antunes.eti.br> To: Mark Heintz PHP Mailing Lists <heintzphp@mail.groupm7.com> Cc: PHP-GENERAL <PHP-GENERAL@lists.php.net> Sent: Monday, March 18, 2002 11:18 PM Subject: [PHP] More on: how to send a file to the user's browser? > Hi Mark, > > It does not work. What it does is to echo the thing to the screen. > > How can I force the browser to download it with its original file name? > > > > ----- Original Message ----- > From: "Mark Heintz PHP Mailing Lists" <heintzphp@mail.groupm7.com> > To: "Carlos Fernando Scheidecker Antunes" <nando@antunes.eti.br> > Cc: "PHP-GENERAL" <PHP-GENERAL@lists.php.net> > Sent: Monday, March 18, 2002 5:01 PM > Subject: Re: [PHP] how to send a file to the user's browser? > > > > A couple more headers than absolutely necessary, but this should work: > > <?php > // open file and send to user > if($fp = fopen($downloadfile, "r")){ > // output headers > $downloadsize = filesize($downloadfile); > header ( "Expires: Mon, 1 Apr 1974 05:00:00 GMT" ); > header ( "Last-Modified: " . gmdate("D,d M YH:i:s T") ); > header ( "Pragma: no-cache" ); > header ( "Content-type: application/octet-stream; name=$downloadfile" ); > header ( "Content-length: $downloadsize" ); > header ( "Content-Disposition: attachment; filename="$downloadfile" ); > // read out file > fpassthru($fp); > fclose($fp); > } else { > // can't open file > } > ?> > > > mh. > > > On Mon, 18 Mar 2002, Carlos Fernando Scheidecker Antunes wrote: > > > Hello all, > > > > I've got a script that generates a txt file, compresses it into a Zip file > and it all happens on a directory that is out of apache's web site. > > > > This script generates the file based on MySQL server information and I > have it then sent to the user's e-mail address. What I would like to do is > to make the PHP script "throw" the file to the user's browser so that it > would download it automatically. This file is created on a directory that is > not the same as the web server where the pages and php scripts are located. > > > > Anyone could help me with that? > > > > Thanks. > > > > regards, > > > > Carlos Fernando Scheidecker Antunes > > Linux User #207984 > > > > > > > -- > 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 > >

« previous php.general (#89063) next »