The code for download that works at localhost is but live at hostgather server it throughs error
ob_get_clean();
header("Content-type: text/x-csv"); # DECLARING FILE TYPE
header("Content-Transfer-Encoding: binary");
header("Content-Disposition: attachment; filename=".$csv_file_name); # EXPORT GENERATED CSV FILE
header("Pragma: no-cache");
header("Expires: 0");
echo $fields;
exit;
The error is
Warning: Cannot modify header information – headers already sent by (output started at /home/londoner/public_html/pkfones.com/pinquest/wp-admin/includes/template.php:1679) in /home/londoner/public_html/pkfones.com/pinquest/wp-content/plugins/wp-gamesize/setgamesize_admin.php on line 131
Make sure you’re calling
ob_start()
at the beginning (or very close) of your code execution. This will buffer all your output and allow you send headers any time. You can probably just place this at the very top of your functions.php.The reason this works on your local and not live is probably a difference in the server config, where locally you are buffering by default but not on live. This is a good reason to make sure that your development and production environments are as similar as possible.