Im confused by an estate agency vebra import script that worked fine before it was moved to a different server however now this seems to not work at all.
Does anyone have any idea why i would get the following warnings…
Warning: ftp_get() [function.ftp-get]: Opening data channel for file
transfer. in
/home/username/public_html/includes/cron/import/vebra-import.php on
line 37Warning: ftp_get() [function.ftp-get]: Transfer OK in
/home/username/public_html/includes/cron/import/vebra-import.php on
line 37
here is the ftp connection code:
$ftp = ftp_connect($ftp_host, 21) or die("FTP Connection Error");
ftp_login($ftp, $ftp_user, $ftp_pass) or die("Can't Connect to FTP");
$ftpdir = ftp_nlist($ftp, "/");
if(!empty($ftpdir) && count($ftpdir) > 0) {
foreach($ftpdir as $ftpfile) {
if(preg_match("/\.txt$/", $ftpfile)) {
$getfile = ftp_get($ftp, $csv_dir.$ftpfile, $ftpfile, FTP_BINARY);
if($getfile){
$downloaded++;
}
$total++;
}
}
}
ftp_close($ftp);
Furthermore, it seems to be intermittent, and sometimes this executes successfully other times it fails with the above errors.
Your server is not in a passive mode, and add this code to process:
For more information look at passive mode on php.net: http://php.net/manual/en/function.ftp-pasv.php
Passive mode uses the data initiated by the client rather than the server. So this is why you can’t put on server. If this is not set it will fail.
NOTE: Set
ftp_pasv()function afterftp_login()function.