【发布时间】:2018-12-21 02:27:31
【问题描述】:
我尝试从服务器中的 php 强制下载 pdf 文件...但我下载的所有文件只有 1kb 大小。它与实际大小不同,我需要在下载前声明文件大小吗?
<?php
$path = "C:\Users\omamu02\Desktop\TESTPRINT" ;
$file = "NMT PRV PHG 370 2017.pdf";
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-disposition: attachment; filename= $file"); //Tell the filename to the browser
header("Content-type: application/force-download");//Get and show report format
header("Content-Transfer-Encoding: binary");
header("Accept-Ranges: bytes");
readfile($path); //Read and stream the file
get_curret_user();
error_reporting(0);
?>
【问题讨论】: