[thelist] Header Problems with file downloads

sbeam sbeam at syxyz.net
Fri Mar 12 06:11:40 CST 2004


On Thursday 11 March 2004 14:23, The Lists wrote:
>
> file_put_contents_php4("data.csv", $output);
> # creates csv file and outputs it to data.csv
>
> header("Content-type: application/csv;");
> header("Content-disposition: attachment; filename=data.csv");
>
> But when I open the csv file it is just the current web page and NOT
> the csv file in question...I presume it is the headers which are
> wrong..any suggestions please?

It looks like you are creating a data.csv separately on the server 
somewhere. If so you will want to redirect to that with 
header('Location: data.csv') instead. Or fopen() the file and stream it 
manually.

Which by the way you don't have to do, you could just put a 
echo($output) after the headers and that would theoretically work.

# S Beam - Web App Dev Servs
# http://www.onsetcorps.net/


More information about the thelist mailing list