File upload does not function consistently