2012-06-26 56 views

回答

0

对于Apache,你可以建立一个目录别名,即:

Alias /download /var/www/download 
<Directory /var/www/download> 
    Order allow,deny 
    Allow from all 
</Directory> 

或者你可以简单地使用符号链接此任务:

ln -s /var/www/download /var/www/myproject/download 

确保启用您的Web服务器的符号链接。

+0

上面的一个是目标pdf用户必须下载...我真的很震撼.......这是现场直播... –

0
<?php 
    $file = '/full/path/below/root/secret.pdf'; 

    header('Content-Description: File Transfer'); 
    header('Content-Type: application/octet-stream'); 
    header('Content-Disposition: attachment; filename=' . basename($file)); 
    header('Content-Transfer-Encoding: binary'); 
    header('Expires: 0'); 
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 
    header('Pragma: public'); 
    header('Content-Length: ' . filesize($file)); 
    ob_clean(); 
    flush(); 
    readfile($file); 
    exit; 
?> 
+0

John谢谢你的回复,$ file ='/full/path/below/root/secret.pdf';只是混淆。我的根目录是www/myproject。我需要在www/download/file.pdf中添加下载文件夹。现在你可以看到www/myproject和www/download。那么我该如何给路径。 –