Re: Help w/ 'headers already sent' and file download

From: Date: Tue, 16 May 2006 08:33:15 +0000
Subject: Re: Help w/ 'headers already sent' and file download
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-236267@lists.php.net to get a copy of this message
Mike Walsh schrieb:
I have an application which I am working on which takes a file supplied by the user via a File Upload, peforms some processing on it, then prompts the user to download a generated CSV file. What I would like to do is report some processing statistics prior to the user prior to sending the CSV steam. My CSV export ends with this:
        header("Content-type: application/vnd.ms-excel") ;
        header("Content-disposition:  attachment; filename=CSVData." . date("Y-m-d").".csv") ;
        print $csvStream ;
Unfortunately if I display any content prior to sending the CSV stream I get the 'headers already sent' error message. Is there a way to both display a web page and send content to be saved by the user? If someone knows of an example I could look at I'd be greatful. Split the page.
One php page showing the content and the second generating the csv file. Call that script with Javascript when the page is load. That way you could display the content and download the file. Greets Barry -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

« previous php.general (#236267) next »