Your has a little weak point that you have to write separated function for each of your file input.
If file input has some specific attributes: name, class, etc.
You should not forget to update it when original html will be changed.
Here is more universal solution.