This function checks if an uploaded filename already exists in a server if it does then it generates a unique name and saves it to the databae