Problem with FTP Upload Done

Hi, Happy New Year for all of you…

I have a problem trying to catch the end of uploading files, i have a list of images that have to upload to my server, everything is allright with upload, the files have been upload ok but when i want to do something at the end i am not able to detect when the last file was upload, the Upload Done show the Alert (or does something) everytime ALTHOUGT in the if statement i am checking if the number of file is the last of the list… do you have any idea of what is wrong?