I am connecting to an FTP and downloading a file. The file name is based on date, so 10242011.csv would be the file the script tries to download today. Sometimes the file does not exist for a day. I have the following code, but I still receive a php warning:
Warning: ftp_fget() [function.ftp-fget]: 10242011.csv: The system cannot find the file specified. in /home/rick/public_html/cron/main.php on line 68
Here is the code:
if (!ftp_fget($conn, $handle, $ftp_file, FTP_ASCII, 0)) {
$log[] = array('type' => 'error', 'msg' => 'Unable to download data file (' . $ftp_file . ') from ftp.');
email_fatal_error(); exit();
} else {
$log[] = array('type' => 'success', 'msg' => 'File downloaded.');
}
I know I could just turn of php warings, but I just want to know the "right" way to do this. Anytime you receive a warning I feel like it could be solved.