I have made a custom plugin, which exports MYSQL table contents into a .csv file which gets saved in to wp uploads directory. Now, I am trying to give a download link for downloading directly a .csv file. But, I am getting this error "Warning: Cannot modify header information - headers already sent"
I'm so very grateful for all of the help you all give. I've searched for this topic and couldn't find it, if this topic is already answered here, please comment with the link to the question with the answer.
Code Which I tried for Downloaing:
header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ); header( "Content-Length: " . strlen( $out ) ); // Output to browser with appropriate mime type, you choose ;) header( "Content-type: text/x-csv" ); header( "Content-Disposition: attachment; filename=$filename" ); echo $out; exit;