I am uploading a file to a server using FileReference and a upload script in PHP.

I find that it sometimes timeouts from the server. What would be the correct way to handle the timeouts. Is there a listener function that would take care of this for me?