0
我有一個公共功能下載JSON文件。我希望在下載完成後重定向到索引(base_url
)。我嘗試使用ob_start
和ob_flush
PHP函數,但那不行。這可能嗎?強制下載後的Codeigniter重定向
$this->load->helper('url');
$data['events'] = $this->events_model->get_events();
ob_start();
header("Content-Description: File Transfer");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename='EVENTS.json'");
echo json_encode($data);
ob_flush();
redirect(base_url());
你檢查,[這](http://stackoverflow.com/questions/822707/ PHP-生成文件換版,然後重定向)? – user1190992 2013-04-10 14:05:34
您無法在相同的HTTP響應中提供下載數據_and_重定向。 – CBroe 2013-04-10 14:15:01