PHP output to file for download without creating file on the server
I would like to output my data to a file for the user to download without actually creating the file physically on the server. The data of the file is simply array that I'm converting into a CSV format for the user to download. Here's my code: $fh = fopen('file.csv','w'); fputcsv($fh,$arr); // $arr is my array that contains the data to be parsed into CSV fclose($out); The above code creates the file successfully... but I don't want to have to create a file. I want to simply stream the output. Any help would be greatly appreciated! You can use header("Content-type: text/csv"); header("Cache