The logic for templates upload.