生成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
关于修复的任何想法或为什么会发生都是很好的!
答案 0 :(得分:0)
请检查您服务器上的mod_sec
是否将请求标记为试图进行文件注入攻击,并返回错误显示为ERR_INVALID_RESPONSE
的403禁止响应。