New method of handling file upload button

From #3203.