Page 1 of 1

[SOLVED] header('') Problem

Posted: Sun Jun 13, 2004 2:22 am
by bluenote
Hi there,

i have coded an export tool which extracts data from a MySQL DB into XML. In order that the users of this tool don't need to change the extension from .php to .xml or to type in the filename, i have added these headers to the main script:

Code: Select all

<?php
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Type: application/force-download');
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename="test.xml"');
?>
This works quite well. But now i want (in fact, i have to :lol: ) change the filename dynamically in relation to the data exported (i. e. if all articles from 2004 have been selected, the file should be named something like 'artic-2004-all.xml').

Is it possible to insert variables in the header line? Or is there any other trick to do this?? I know that this is maybe a stuuupid question, but it's killing me.

Thanx in advance for help,
- bluenote

Posted: Sun Jun 13, 2004 2:25 am
by markl999

Code: Select all

header('Content-Disposition: attachment; filename="'.$filename.'.xml"');

Posted: Sun Jun 13, 2004 2:50 am
by bluenote
THANX markl999 !!

This works! Prob solved.

- bluenote