'File name cannot be empty ftp_get
Downloading multiple files from ftp and files are present on server, My code works and prints the filename from ftp but cant download the file.
$login_result = ftp_login($con, $server['stager_usr'], $server['stager_pwd']);
ftp_pasv($con, true);
$now = time();
$yesterday = $now - (24 * 60 * 60);
$date = date("Y-m-d", $yesterday);
if (isset($_GET['date'])) {
$date = $_GET['date'];
}
$date_dir = strftime("/%Y-%m-%d", $yesterday);
$date_dir = $server['basedir'].$date_dir;
$path = $server['basedir'];
$serverDir = $_SERVER['DOCUMENT_ROOT'];
$imagesTop = "/CSV";
$startDate = "$date 00:00:00";
$endDate = "$date 23:59:59";
$files = ftp_nlist($con,$date_dir);
$date_dir = strftime("%Y-%m-%d", $yesterday);
$date_dir = $path . $date_dir;
foreach ($files as $file)
{
if (preg_match("/\.csv$/i", $file))
{
echo"\n Found $file \n";
ftp_get($con, $serverDir, $file, FTP_BINARY);
}
}
}
ftp_close($con);
}
}
//}
?
PHP Warning: ftp_get(): Filename cannot be empty in /usr/local/bin/camftp.php o n line 126 PHP Warning: ftp_get(): Error opening in /usr/local/bin/camftp.php on line 126
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
