Soldato
- Joined
- 16 Nov 2003
- Posts
- 9,682
- Location
- On the pale blue dot
I have a load of data in a mysql table that using a php script I have created reformats it as a csv, the idea being that users can click a link to the script and a download link pops up for them to save the csv to disk.
I've been trawling the interweb for info on how to take my data and force the browser to show the download file dialog. The key seems to be 'header' calls but I can't seem to get it to work. The code so far:
Where data is a string of info which makes up the csv content.
I've been trawling the interweb for info on how to take my data and force the browser to show the download file dialog. The key seems to be 'header' calls but I can't seem to get it to work. The code so far:
Code:
header("Content-type: text/plain);
header("Content-Disposition: attachment; filename=info.csv");
printf "$data";
Where data is a string of info which makes up the csv content.