add validation to upload function