im trying to give the user ability to download a specific file. here is my code.
but it keeps adding .txt after the file is downloaded which I want is a .csv
<
I'm pretty sure that your browser can't interpret the file. According to this solution, you need to force it to open 'save as...' dialog:
$headers = array( 'Content-Type: text/csv', 'Content-disposition: attachment' );