在ubuntu上下载php force

时间:2011-04-27 09:06:44

标签: php ubuntu download

我有一个php脚本,可以在Windows上正常工作,强制从外部链接文件下载文件。我的意思是在我的计算机上下载并阅读已完成的已下载文件 但是在我的ubuntu下同样的代码下载,但阅读它是一个大问题。我有“眼睛的侏儒”的错误:=解释JPEG图像文件的错误(不是JPEG文件:以0x3c 0x70开头)= 也许我必须改变标题我认为这样但是......任何想法都会欢迎thx

// required for IE, otherwise Content-disposition is ignored    
if (ini_get('zlib.output_compression'))
            ini_set('zlib.output_compression', 'Off');

// addition by Jorg Weske
        //$file_extension = strtolower(substr(strrchr($filename, "."), 1));
        header("Pragma: public"); // required
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: private", false); // required for certain browsers
        header("Content-Type: application/force-download; name=\"$filename\"");
// change, added quotes to allow spaces in filenames, by Rajkumar Singh
        header("Content-Disposition: attachment; filename=\"" . basename($filename) . "\";");
        header("Content-Transfer-Encoding: binary");
//header("Content-Length: ".filesize($filename));
        readfile("$filename");
        exit();

1 个答案:

答案 0 :(得分:1)

0x3c 0x70 = <P。您确定您的PHP脚本在JPEG数据之前没有发送任何HTML吗?该脚本还可能生成在JPEG数据之前发送的警告或通知。