PHP脚本不能在托pipe系统上工作

我有以下脚本可以在本地系统上运行,但不能在networking主机系统上运行(需要它)。 在本地,它没有问题下载文件。 托pipe时,我得到零或低字节文件,而不是整个文件。

<?php $username = "user"; $password = "password"; $server = "ftp.domain.com"; $path = $_GET['p']; $filename = $_GET['f']; $file_full = $path."/".$filename; $file_path = "ftp://".$username.":".$password."@".$server."/".$file_full; $fsize = filesize($file_path); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Description: File Transfer"); //header("Content-Type: $mtype"); header("Content-Type: application/octet-stream"); //header("Content-Disposition: attachment; filename=\"$asfname\""); */ header("Content-Disposition: attachment; filename=\"$filename\""); header("Content-Transfer-Encoding: binary"); header("Content-Length: " . $fsize); // download // @readfile($file_path); $file = @fopen($file_path,"rb"); if ($file) { while(!feof($file)) { print(fread($file, 1024*8)); flush(); if (connection_status()!=0) { @fclose($file); die(); } } @fclose($file); } ?> 

我的主机提供商是Hostmonster(如果有帮助的话)。

如果你想知道,我知道我可以通过FTP下载链接,但我需要强制用户select是“另存为”或“打开”,因此脚本。

您正尝试通过您的Web服务器来传输/转发远程FTP内容; 那里有十几件事情可能会出错。

最明显的是如果FTP机器不支持检索文件大小和计算的fsize是不正确的。

我们只是说这几乎不是正确的解决scheme。