-------------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,看看效果
<?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,看看效果
echo file_get_contents($_GET[id].'.gif');
这句改为
readfile($_GET[id].'.gif');
好点file_get_contents在旧版本的PHP环境下不适用
假如是.rar压缩文件,png文件,.doc.文件,它只会出现很多文字,请问一下,怎样才能够出现下载的对话框
header('Content-Disposition: attachment; filename='.$file);//作为附件下载
readfile($file);