Jump to content

User downloads a csv file


carlg

Recommended Posts

What is the best way to have a user download a csv file?

 

I can create the file, but when the user clicks on a link to the file it actually displays the file in the browser.

 

I want it to have the popup box where it says "Where do you want to save this file?"

 

and allows the user to save it.

 

How can I do this?

 

Thanks

 

Carl

 

Link to comment
https://forums.phpfreaks.com/topic/74383-user-downloads-a-csv-file/
Share on other sites

this works for me

<?php
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=aaa.csv");
header("Pragma: no-cache");
header("Expires: 0");

echo "a,b,1\n";
echo "d,e,2\n";

?> 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.