1
$source_path = 'https://bip.wzp.pl/attachments/' . $filename;
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Content-type: application/pdf",
)
);
$context = stream_context_create($opts);
$data = file_get_contents($source_path, false, $context);
if(($handle = fopen($dest_path, "w"))) {
fwrite($handle, $data);
fclose($handle);
return $filename_converted;
}
$source_path
은 예컨대 :file_get_contents를 통해 파일을 다운로드하여 손상된 파일을 가져 오는 이유는 무엇입니까?
https://bip.wzp.pl/attachments/28172_Statut Województwa Zachodniopomorskiego.pdf
내가 브라우저를 시도하고, 적절하게 PDF 문서 디스플레이의.
그러나 PHP를 통해 다운로드 한 파일은 항상 손상되었습니다.
편집 나는 $data
내용을 확인. 그것은 첫 페이지의 HTML을 가지고 : 그것은 브라우저에 $source_path
퍼팅 당신이 PDF 파일을 다운로드하려고 같은 PDF
감사하지만 내 문제는 $ data에 pdf 내용 대신 완전히 다릅니다. html :/ – keram
요청한 URL을 URL 인코딩 해보십시오. –
전에 $ filename에 urlencode를 시도했지만 URL이 바뀌었고 브라우저의 pdf 대신 항상 프론트 페이지로 바뀌 었습니다. – keram