File php文件强制下载错误

File php文件强制下载错误,file,File,我正试图强制下载。这是我的密码: <?PHP // Define the path to file $file = 'http://myimage.com/users/test/uploads/1234.png'; if(!file) { // File doesn't exist, output error die('file not found'); } else { header('Content-disposition: attach

我正试图强制下载。这是我的密码:

 <?PHP
 // Define the path to file
 $file = 'http://myimage.com/users/test/uploads/1234.png';

 if(!file)
 {
     // File doesn't exist, output error
     die('file not found');
 }
 else
 {
     header('Content-disposition: attachment; filename='.$file);
    header('Content-type: application/octet-stream');
    readfile($file);
}
?>

您的
内容类型
错误。强制下载只需
内容配置:附件
;将其更改为
image/png
,而不是
application/octet-stream


另外,您在打开
之前有一个空格,请确保
标记外没有任何空行。

好的。所以文件不存在!陛下真奇怪。。。变量$file destination可在浏览器中查看。。为什么它不能下载它?@droidus:文件在另一台服务器上吗?您的防火墙可能正在阻止它,或者远程
fopen
可能被禁用。嗯,它正由其他人托管,是的。如何检查fopen是否被禁用?@droidus:进入
php.ini
并将
allow\u url\u fopen
更改为
On
。如果它已经在
上,您可能需要取消阻止PHP.hm的端口80上的传出连接,但不确定它们是否允许我访问该端口。。。我必须和他们核实一下。。。在此期间我还能做些什么吗?