ERR_INVALID_RESPONSE:php excel导出codeigniter

时间:2018-06-13 14:30:37

标签: php codeigniter

从数据库导出客户端时出错。当离线使用代码时,如果我将其集成到我的Web应用程序中,我会收到错误。

代码很简单,我尝试在CodeIgniter应用程序中导出到CSV文件。

错误:无法访问此站点sitename.be/beheer/clients/export上的网页可能已被暂时禁用或永久移至新的网址。 ERR_INVALID_RESPONSE

控制器:

public function export(){

    // file name
    $filename = 'users_'.date('Ymd').'.csv';

    header("Content-Description: File Transfer");
    header("Content-Disposition: attachment; filename=$filename");
    header("Content-Type: application/csv; "); 

    // get data
    $usersData = $this->Client->getUserDetails();

    // file creation
    $file = fopen('php://output', 'w');

    $header = array("reference","Name","client_id","phone","mobile","address","zipcode","city","inactive","website","country","vat","note","province","twitter","skype","linkedin","facebook","instagram","google","youtube","pinterest","terms");
    fputcsv($file, $header);

    foreach ($usersData as $key=>$line){
     fputcsv($file,$line);
    }

    fclose($file);
    exit;
}

型号:

function getUserDetails(){

    $response = array();

    // Select record
    $this->db->select('*');
    $q = $this->db->get('companies');
    $response = $q->result_array();

    return $response;
}

查看

blueline->客户 - >这一切都是我的观点所在的地图

这是我的观点代码

  < a href='<?= base_url() ?>clients/export' class="btn btn-primary">Export</a>

0 个答案:

没有答案