大家好我正在开发一个PHP MVC框架,我达到了一个我需要为用户提供一些文件的地步,我不知道如何创建下载链接我知道它听起来很幼稚但我试图制作超链接文件的地址,但似乎不起作用....有些文件是理想的
答案 0 :(得分:4)
$fullpath = $_SERVER['DOCUMENT_ROOT']."/foldername/document.pdf"; //Full path of document
$filename = "document.pdf"; //Document file nmae
$mm_type="application/octet-stream";
header("Cache-Control: public, must-revalidate");
header("Pragma: hack");
header("Content-Type: " . $mm_type);
header("Content-Length: " .(string)(filesize($fullpath)) );
header('Content-Disposition: attachment; filename="'.$filename.'"');
header("Content-Transfer-Encoding: binary\n");