$file = "http://www.abax.se/content/download/137/862/file/example.pdf";
header('Content-Description: File Transfer');
header('Content-Type: application/pdf');
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));
flush();
readfile($file);
这是我正在运行的代码,我出来的想法,任何解决方案?PHP下载给我空PDF
删除'平齐()'? – Daan 2014-09-26 13:30:39
同样的东西,空的下载pdf ... – josaric 2014-09-26 13:38:01
这段代码看起来很奇怪。为什么要下载文件才能上传?你为什么不直接发送“301永久移动”响应,将用户直接发送到文件?该文件是否与此代码位于同一台服务器上?如果是这样,那么你不应该通过HTTP;您应该直接从服务器读取并输出文件。 – 2014-09-26 13:38:08