Fork a child to start FTP session, then scan that directory for files and upload any it finds and then unlink them - scan/sleep/scan/sleep/scan/upload etc..
create the files elsewhere and move to the tmp dir when created (using flock to stop the FTP process from grabbing partial files too early).
when last file is created, parent sets a marker somewhere that the FTP child can read to know that "no more files are coming", and then quits
child continues to ftp and unlink files it finds in the tmp dir. When done, it unlinks the tmp directory, closes FTP sesison and quits.