关于文件下载的问题
为了防止匿名用户下载文件,我在校验用户权限后用一下代码输出文件:
$file = fopen($record['path'],"r");
Header("Content-type: application/octet-stream");
Header("Accept-Ranges: bytes");
Header("Accept-Length: ".filesize($record['path']));
Header("Content-Disposition: attachment; filename=" .basename($record['path']));
echo fread($file,filesize($record['path']));
fclose($file);
但是用户不能在网页中直接浏览该文件,比如输出文件是PDF格式的时候,不能直接在浏览器中通过Acrobat Reader打开,提示找不到文件路径的错误;而是要先下载再打开!请问各位有什么方法可以解决这个问题?