I have a link on my web page to download a .CSV file that I have generated on the server. The code for the download is as follows:
//open/save dialog box
header('Content-Disposition: attachment; filename="inventoryData.csv"');
//content type
header('Content-type: application/excel');
//read from server and write to buffer
readfile('spreadsheet/inventory.csv');
When I open the file on the server, it looks just fine. However, when I download the file via the dialog box, it is pre-pending the HTML code for the web page to the .csv file.
Any ideas why that would happen?