$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
例:
https://bip.wzp.pl/attachments/28172_Statut Województwa Zachodniopomorskiego.pdf
ブラウザで試してみると、pdf ドキュメントが正しく表示されます。
しかし、PHP経由でファイルをダウンロードすると、常に破損しています。
編集
内容を確認$data
しました。それはフロントページのhtmlを持っています:/$source_path
ブラウザに置くのは奇妙なことですpdfを返します