Added a check for existing files before uploading