I modified the server again to get rid of some unnecessary code for upload. It was creating a file descriptor.