我嘗試使用ftp_get() 檢索的文本文件,當我執行該腳本,我得到警告:獲取有關ftp_get警告()在PHP
ftp_get() [function.ftp-get]: Can't open data connection
一些人能給出一些線索,什麼是錯的。這是我以前的託管/服務器,因爲我把它打破了。是否有一些特定的PHP配置。我檢查了phpinfo並啓用了FTP支持。 連接獲取資源ID,用戶名,密碼和ftp主機通過CuteFTP工作。
function _getFtpFile($fileName = '') {
if($fileName == '') {
return false;
}
$model = $this->getModel();
$params =& $model->getParams();
$vebraHost = $params->get('vebra_host');
$vebraUser = $params->get('vebra_username');
$vebraPass = $params->get('vebra_password');
$localFile = JPATH_BASE.'/tmp/tmp.csv';
// Delete the file in case it exists
@unlink($localFile);
// set up basic connection
$connId = ftp_connect($vebraHost);
// login with username and password
$loginResult = ftp_login($connId, $vebraUser, $vebraPass);
// turn on passive mode transfers
ftp_pasv($connId, true);
// try to download $server_file and save to $localFile
if (!ftp_get($connId, $localFile, $fileName, FTP_BINARY)) {
$file = false;
} else {
$file = $localFile;
}
// close the connection
ftp_close($connId);
return $file;
}
權限是755 – infinity 2010-10-28 17:26:03