Check out flock for more information on this. flock will try to lock a file. It will fail if it can't, meaning the file is in use or otherwise inaccessible.
-peter
Edit: As Abigail-II pointed out, this won't really help you over FTP. I should've read your question more thoroughly, but flock is a place to start.