0
你好我的网站上有一些pdf文件,用户可以下载,但问题是当我们下载这些pdf文件并尝试打开pdf时出现错误“打开文件。文件已损坏,无法修复“,但在我的本地系统中工作正常。 请指引我,这里是我的代码pdf文档下载时出错
function download_pdf($parameters)
{
$final_link = "$parameters";
$path = strtolower($final_link);
$file = "$path";
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
else
{
//echo "file do not exist";
redirect('site/file_does_not_exist');
//$data['main_content'] = 'not_found';
//$this->load->view('includes/template',$data);
}
}