[SOLVED]Force Download, can't modify header

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Bain
Forum Newbie
Posts: 5
Joined: Mon Sep 06, 2004 4:32 pm

[SOLVED]Force Download, can't modify header

Post by Bain »

I am trying to force a download of a .csv file from a form which calls it self. here is the code I am using. Is there no way to modify the header on a page that calls it self? What exactly do I need to do to get this download to go?

Code: Select all

<?php
$file2 = "orders.csv";
       Header ("Content-Type: text/csv");
       Header ("Content-Disposition: attachment; filename=$file2");
       readfile($file);
?>
here is the error message I receive from IE when I try to execute.
Warning: Cannot modify header information - headers already sent by (output started at directoryinfo/stats.php:50) in directoryinfo/stats.php on line 509

Warning: Cannot modify header information - headers already sent by (output started at directoryinfo/stats.php:50) in directoryinfo/stats.php on line 510
Last edited by Bain on Tue Sep 07, 2004 9:33 am, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

line 50 of stats.php wrote something to the output.
viewtopic.php?t=1157
Post Reply