0

我有一个下载 JSON 文件的公共函数。我希望它base_url在下载完成后重定向到索引()。我尝试使用ob_startob_flushPHP 函数,但没有这样做。这可能吗?

    $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());
4

1 回答 1

0

'echo' 后函数 redirect() 不起作用;

重定向之前,您无法在浏览器中回显任何内容

请评论这一行:

//echo json_encode($data);
于 2013-04-10T14:09:40.843 回答