PHP CSV create then echo javascript redirect -
i creating csv file in php, no biggie there, , force downloading user, again no biggie there. problem coming across redirect portion. know cannot create file , push user , use php redirect afterwards, kills csv creation due http protocols. instead, doing javascript redirect follows:
echo '<script>'; echo ' window.location = "'.base_url().'link/'.$item_id.'"'; echo '</script>'; die; this works fine (it reloads page), portion above echoed gets added on csv file when downloaded. here php code creates csv , force downloads it:
fwrite($csv, $csv_data); fclose($csv); header('content-type: application/vnd.ms-excel'); header('content-length: ' . strlen($csv_data)); header("content-disposition: attachment; filename=$file_name"); readfile($file_path); what missing in terms of not having <script> text getting appended csv?
thanks in advance.
Comments
Post a Comment