0
안녕하세요 사용자가 다운로드 할 수있는 웹 사이트에 일부 pdf 파일이 있지만 문제는 우리가이 pdf 파일을 다운로드하고 pdf를 열 때 오류가 발생하는 것입니다. 파일이 손상되어 복구 할 수 없습니다. "하지만 contarary에서는 로컬 시스템에서 정상적으로 작동합니다.다운로드에서 PDF 문서 오류
...
header('Content-Type: application/pdf');
...
application/pdf: Portable Document Format
Internet media types in wikipedia:에서 또한 파일 이름에 확장자를 "이 있는지 확인 : 나를 인도 해주십시오, 여기에 내 코드
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);
}
}