Hello... I would tackle this problem in
PERL, but for now I wanted to address options for knowing if the file upload is complete... The usual way to do this is to have the person or software that does the uploading to RENAME (ftp REN command) to another directory in the same file system. Because a RENAME (like a mv move in the shell) only changes pointers, the process is instantaneous and so if the file appears in the moved-to directory, you know it must be complete....
so for example...
../uploaddir/commitdir
You UPLOAD files to the uploaddir and when the upload is finished issue a command like ftp> REN uploadedfile commitdir/uploadedfile
Your process polls commitdir, not the uploaddir. If a file appears in commitdir, you know it must be fully uploaded and closed.