Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Codeigniter 我无法在服务器上下载我的pdf文件_Codeigniter_Pdf - Fatal编程技术网

Codeigniter 我无法在服务器上下载我的pdf文件

Codeigniter 我无法在服务器上下载我的pdf文件,codeigniter,pdf,Codeigniter,Pdf,当我试图生成pdf格式的报告时,exel。 如果我想下载到excel,它在每个功能中的工作方式。 当我试图将报告下载到pdf时,在某些功能中它可以工作,但在某些功能中它给了我这个错误 禁止的 您没有访问此服务器上的/sc/reports/home/print\u admin\u报表的权限 此外,尝试使用ErrorDocument处理请求时遇到404 Not Found错误 有什么需要帮忙的吗 注意:本地服务器没有问题,只有在线服务器有问题 提前感谢这在本地和服务器上都适用,请尝试一下 func

当我试图生成pdf格式的报告时,exel。
如果我想下载到excel,它在每个功能中的工作方式。

当我试图将报告下载到pdf时,在某些功能中它可以工作,但在某些功能中它给了我这个错误

禁止的

您没有访问此服务器上的/sc/reports/home/print\u admin\u报表的权限

此外,尝试使用ErrorDocument处理请求时遇到404 Not Found错误

有什么需要帮忙的吗

注意:本地服务器没有问题,只有在线服务器有问题


提前感谢

这在本地和服务器上都适用,请尝试一下

function download()
{   
    $base_location = 'files/';
    $FILENAME_VAR = 'YOURFILENAME.pdf';
    if ($FILENAME_VAR)
    {
        header('Content-Description: File Transfer');
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename='.$FILENAME_VAR);
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Cache-Control: must-revalidate');
        header('Pragma: public');
        header('Content-Length: ' . filesize($base_location . $FILENAME_VAR));
        ob_clean();
        flush();
        readfile($base_location . $FILENAME_VAR);
    }
}

将$base_位置和YOURFILENAME.pdf替换为您的,然后在您的页面中创建指向此方法的链接

您是否授予您的apache/www数据读取该文件夹的权限?是的,在同一文件夹上,某些控制器上另一个功能正在工作,