1👍
The file uploads because when you submit the form, the request sent to the server includes the file.
One way you may approach this if you need to validate other fields first is maybe use some Ajax or as you suggest, front-validation with javascript. But remember, front-end validation is never enough. You can have front-end validation for performance purposes and client satisfaction but always perform a full server side validation.
This link may help you with what you want.
Hope this helps!
Source:stackexchange.com