Use PHP to write a META-REFRESH to the file that's going to be downloaded,
or a php file that controls the download. Basically, you show them an HTML
page that says the download will begin, the META tag refreshes after X
seconds to the actual file, and the download box pops up.

---John Holmes...

----- Original Message -----
From: "D. D. Brierton" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, May 21, 2002 3:37 PM
Subject: [PHP] How to simultaneously send HTML *and* start download?


> The result I'm looking for is like the CGI script at netscape for
downloading
> NS6 - it takes you to a page which says aomething like "The download
should
> start automatically" and then the download begins. I'm having trouble
figuring
> out how to do this in PHP - I suspect through ignorance of the appropriate
> HTTP headers. Am I looking for something like Content-type: multipart? So
what
> I'm looking to achieve is a bit like what this obviously fails to do (but
> hopefuly you can see what I'm aiming at):
>
> <?php
>   $fp = fopen("myfile.foo","r");
>   header("Content-type: application/foo");
>   header("Content-Disposition: filename=myfile.foo");
>   fpassthru($fp);
>   fclose($fp);
> ?>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>   "http://www.w3.org/TR/html4/loose.dtd";>
> <html>
>   <head>
>     <title>Download</title>
>   </head>
>   <body>
>     <p>The download should start automatically. If it does not, right
click
>     the following link and choose "Save as ..."</p>
>     <p><a href="myfile.foo">Download MyFile</a></p>
>   </body>
> </html>
>
> Obviously what actually happens with the above is that the HTML after the
PHP
> script is appended to myfile.foo.
>
> Can anyone point me in the right direction?
>
> TIA, Darren
>
> --
> ======================================================================
> D. D. Brierton            [EMAIL PROTECTED]           www.dzr-web.com
>         Trying is the first step before failure (Homer Simpson)
> ======================================================================
>
> --
> 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

Reply via email to