Refactored file upload into the fileselect directive