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

Reply via email to