Check the file size just before uploading

Make sure not to overwrite a valid upload with a truncated one.