图像下载不起作用。它直接读取而不是下载。
if($_REQUEST['image'] == true){
$URl = $post->guid;
echo $URl;
header("Content-Type: image/png");
header('Content-Description: File Transfer');
header("Cache-Control: no-cache, validated");
header('Content-Type: application/octet-stream');
header("Content-Disposition: attachment; filename='"".basename($URl)."'"");
header('Content-Transfer-Encoding: binary');
var_dump(readfile($URl));
die;
}
尝试这种头格式,
header("Content-type: application/octet-stream");
header("Content-Length: " . filesize($filename));
header("Content-Disposition: attachment; filename=$filename");
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
fpassthru($fp);