Re: Header's download
| From: | Christian Johansson | Date: | Wed, 01 Dec 2004 14:19:45 +0000 |
| Subject: | Re: Header's download | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-203222@lists.php.net to get a copy of this message | ||
Hello.
I use:
Header("Content-Type: application/download");
Header("Content-Disposition: attachment; filename=export.txt");
Then after this is done I know that I can write stuff to the file like this:
Echo "This will be a line in my file\n";
I am standing in a GUI containing frames.
So I want to give an administrator the rights to choose what to export.
My problem is that when I include the php file "download.php", the
HTML\JAVA code are written to the file.
download.php are containing the headers.
All the export data are written to the file, but also HTML\JAVA.
How can I get around this problem?
I would be very happy if someone has a solution.
Regards
Christian Johansson
The solution:
Use ob_clean()to emty the buffer, Before you use the headers:
ob_clean();
Header("Content-Type: application/download");
Header("Content-Disposition: attachment; filename=export.txt");
http://no2.php.net/manual/en/function.ob-clean.php
That's it!
Regards
Christian Johansson