Can anyone tell me how I can adjust the MIME-headers (I guess?) to have a PHP script generate a text file that would prompt the user to open/save the file in Internet Explorer.
(Similar to the way you download a file of transactions from your bank I guess).
Thanks,
Peter.
Send a text file back to a user
Moderator: General Moderators
- scorphus
- Forum Regular
- Posts: 589
- Joined: Fri May 09, 2003 11:53 pm
- Location: Belo Horizonte, Brazil
- Contact:
This is how I used to do:
The file has .txt extension and the .htaccess on the text file directory with this line:
Hope it helps,
Scorphus.
Code: Select all
<?php
header("Content-Type: text/download");
echo 'test';
?>Code: Select all
AddType application/x-httpd-php .txtScorphus.
- scorphus
- Forum Regular
- Posts: 589
- Joined: Fri May 09, 2003 11:53 pm
- Location: Belo Horizonte, Brazil
- Contact:
Hi webcan,
We at DevNetwork are very happy to help people, but you gotta remember that Google is yet your best friend and you must learn to use it! It saves you and we a lot of time!
Come with me: what do you have in your hands? You can easily figure out words like 'header', 'Content-Type', 'download', sure you can. So try Google first: [google]header Content-Type download[/google] and see what you get in one of the 10 first returned links, something like this:
With best regards,
Scorphus.
We at DevNetwork are very happy to help people, but you gotta remember that Google is yet your best friend and you must learn to use it! It saves you and we a lot of time!
Come with me: what do you have in your hands? You can easily figure out words like 'header', 'Content-Type', 'download', sure you can. So try Google first: [google]header Content-Type download[/google] and see what you get in one of the 10 first returned links, something like this:
Code: Select all
<?php
$fileName = "list.txt";
header("Content-Type: text/download");
header("Content-length: " . filesize($fileName));
header("Content-Disposition: attachment; filename = " . basename($fileName));
readfile("$fileName");
?>Scorphus.