Fixed a bug in uploading files and updated template entity for file fields