How can I copy all the files from FTP, that start with same string, using PHP? I can copy one file, using this code:
if (copy('ftp://testuser:pass@ftpserver/file_20240520170720.MIS','file.MIS')) {
echo "It worked!!!";
}
but I need to copy all the files that start with string file_20240520
.
ftp_rawlist
, ftp_nlist
or ftp_mlsd
.ftp_get
to download the identified files.For an inspiration, a similar question that selects files to download based on a timestamp (rather than a file name):
Downloading only new images from FTP server in PHP