What is the wrong with this code. I am always getting the error like:
Warning: Cannot modify header information – headers already sent by
(output started at
/home/krishnas/Documents/wordpress/wp-admin/menu-header.php:91) in
/home/krishnas/Documents/wordpress/wp-includes/pluggable.php on line
866
$upload_dir = wp_upload_dir();
$basedir = $upload_dir['basedir'];
$baseurl = $upload_dir['baseurl'];
$filename = "products_".date('YmdHis').".xls";
$fp = fopen($basedir.'/'.$filename,'wr');
fwrite($fp,$content_final);
$excell_file = $baseurl.'/'.$filename;
//echo $basedir;
//echo $baseurl;
//exit;
//exit;
wp_redirect($excell_file);exit;}}?>
Make sure there is no blank space or any extra character after ?> of PHP. It’s seen that such errors are usually causes by extra characters after ?> at the end of file. Please check both the files mentioned in the error code. Let us know if this resolves your error.
please review information in this WordPress codex for solving “headers already sent” warnings.