I have a php file that is designed to download CSV files.
header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename=users.csv');
echo $csvOut;
Where $csvOutis the line that I generated in another function.
The problem is that when I go to this PHP file, my browser gives me a 404 file that was not found. This does the same when I delete a row header('Content-Disposition: attachment;filename=users.csv');.
However, I noticed that if I change header('Content-Type: text/csv');to header('Content-Type: text/html');, it will display the contents $csvOuton the screen, but ONLY if it has header('Content-Disposition: attachment;filename=users.csv');been deleted.
This really confuses me, as I have successfully used this code to work with CSV files before, and I don’t see what I am doing (or not doing) that violates it.
Any help would be greatly appreciated!