生成CSV的函数如下:
主csv输出函数:
function admin_getOscrReport(){
$oscr = $this->Oscr->find('all');
$headers = array("Charity ID", "Charity Name", "Registered Date", "Known As", "Charity Status", "Postcode", "Constitutional Form", "Previous Constitutional Form",
"Geographical Spread", "Operations Location", "Purposes", "Beneficiaries", "Activities", "Objectives", "Address", "Website", "Recent Year Income",
"Recent Year Expenditure", "Mail Cycle", "Year End", "Parent Charity Name", "Parent Charity Number", "Parent Charity Country Reg", "Religious Body", "Regulatory Type");
$this->set('oscrs', $oscr);
$this->layout = null;
$this->autoLayout = false;
Configure::write('debug','0');
$filename = "oscr_reporting.csv";
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename=$filename");
header("Pragma: no-cache");
header("Expires: 0");
$data = fopen('php://output', 'w');
fputcsv($data,$headers);
foreach($oscr as $row){
foreach($row as $r){
fputcsv($data,$r);
}
}
fclose($data);
}这将在本地wamp服务器上输出正确的csv文件,但不会在类似的测试服务器环境中输出。已经在多个浏览器上试过了,而且问题是相同的。
获得"ERR_INVALID_RESPONSE“
使用CAKEPHP1.3的
任何关于修复或为什么会发生的想法都是很棒的!
发布于 2018-07-11 08:54:29
请检查服务器上的mod_sec是否将请求标记为文件注入攻击的尝试,并返回错误显示为ERR_INVALID_RESPONSE的403禁止响应。
https://stackoverflow.com/questions/51280707
复制相似问题