I am stuck on atomization of an process to download last modified text files on date wise or today. Here is my code.
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
$contents = ftp_nlist($conn_id, '-rt .');
reset($contents);
function is_txt($file) {
return preg_match('/.*.txt/', $file) > 0;
}
$filtered = array_filter($contents, is_txt);
// download all files in downloaded directory
while (list($key, $value) = each($filtered )) {
if (ftp_get($conn_id, $dir.'\downloaded\'.$value, $value, FTP_BINARY)) {
echo "Successfully written to $value
";
} else {
echo "There was a problem
";
}
}
I got success in getting text files, but not selecting the last modified files, filemtime
is not helping me nor curl.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…