After you have created the file, use this to force a downlaod.
This will downlaod anything, even an html file.

$fileName = basename($downloadFile);
header("Content-disposition: attachment; filename=\"$fileName\"");
header("Content-type: application-download");
header("Pragma: no-cache");
header("Expires: 0");
$fn=fopen($downloadFile,"r");
fpassthru($fn);
fclose($fn);
exit;

py

"No matter what you know, someone will know more :)"

At 12:01 PM 4/11/01 +1000, you wrote:

>"Lindsay Adams" <[EMAIL PROTECTED]> wrote in message
>[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>You are not going to be able to use PHP to tell the client browser to do
>anything.
>
>you are going to have to embed either a java.applet, or javascript to do it.
>I don¹t know a whole lot about either, so I don't know if they are even a
>possibility.
>
>On 4/10/01 2:29 PM, "Nando2" <[EMAIL PROTECTED]> wrote:
>
> > Hello all!
> >
> > I have a PHP4 script that produces a text file and I would like that when
>the
> > user access this script the text content of it was forced to be saved
>meaning
> > that when the user selects it he/she will have the save dialog form to
>save
> > the text file with the filename specified in the header function. So far I
> > have managed to create the text file dynamicaly but still I have to click
>the
> > browser's save button to save the file with the determined filename. I
>wanted
> > it to be forced.
> >
> > Does anyone know how to do it ?
> >
> > Here's the code :
> >
> > <?php
> >
> >   // Carlos Fernando Scheidecker Antunes : Test saving text files with PHP
> >   // this sets the content type as being plain text
> >
> >   header("Content-Type : text/plain; charset=\"iso-8859-1\"");
> >
> >   // this sets the file name
> >
> >   header("Content-Disposition: filename=\"test.txt\"");
> >
> >   // creates the dynamic content of the text file here
> >
> >   print("TextFile test\r\n\");
> >   for ($i=1; $i < 100; $i++) {
> >       print("This is line number ".$i."\r\n");
> >   }
> >
> > ?>
>
>
>try:
>
>header("Content-Type: unknown/unknown");
>....
>browswer won't know what type of file it is, so will prompt to save.. should
>get the file-name right from the other.
>
>bkx
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]


+ ======================
+ Pierre-Yves Lem@ire
+ E-MedHosting.com
+ (514) 729-8100
+ [EMAIL PROTECTED]
+ ======================


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to