revised code for uploading documents