<?php
$path="images/test.jpg";
try{
if(is_file($path)){
if($file=fopen($path,'rb')){
while(!feof($file) and (connection_status()==0)){
$f.=fread($file,1024*8);
}
fclose($file);
}
$outputname="myimage";
header("Content-type:image/jpeg");
header("Content-disposition:attachment;filename=" . $outputname . ".jpg");
print $f;
}else {
throw new Exception("文件路径错误");
}
}catch (Exception $e){
echo $e->getMessage();
}?>请问,运行这段代码为什么没有出现下载对话框,直接在浏览器中显示图片了?我直接抄写书上的代码的。谢谢