-------------aaaa.php----------
<?PHP
if($_GET[user]==100) die("000000000000000");
header("Content-type: image/gif");
echo file_get_contents($_GET[id].'.gif');
?>--------------index.php----------------------------
<a src="aaaa.php?id=1&user=100">不可以下载</a>
<a src="aaaa.php?id=1&user=10">可以下载</a>找个gif图片,在同一目录下保存为1.gif.浏览index.php,看看效果

解决方案 »

  1.   

    从兼容性上~~~
    echo file_get_contents($_GET[id].'.gif');
    这句改为
    readfile($_GET[id].'.gif');
    好点file_get_contents在旧版本的PHP环境下不适用
      

  2.   

    surfchen(冲浪) ,其他的高手,readfile($_GET[id].'.gif');
    假如是.rar压缩文件,png文件,.doc.文件,它只会出现很多文字,请问一下,怎样才能够出现下载的对话框
      

  3.   

    你可以使用PHP的身份验证来限制目录访问~~~或者直接配置服务器的访问权限~~~至于readfileheader("Content-type: image/gif");你修改一下CONTENT-TYPE就可以了~~
      

  4.   

    content-type 已经改成了header("Content-type:application/vnd.ms-word");还是一段乱码
      

  5.   

    用 apache 做认证可能能满足你的要求
      

  6.   

    http://dev.csdn.net/article/41/41103.shtm
      

  7.   

    header("Content-Type:application/msword");//WORD文件
    header('Content-Disposition: attachment; filename='.$file);//作为附件下载
    readfile($file);