Earlier browsers did not support HTML5 File API, so normally people would use flash or Java Applets to validate file format and sizes in HTML upload forms, and most of us preferred to skip the client part letting server handle the problem.
But in recent years, the HTML5 is doing wonders, it comes with many features including the client-side file objects manipulation (File API). Which means no more 3rd party plug-ins such as flash or Java applets.
Here’s what I did to an upload form that uses jQuery.
The code below contains the HTML file input field and a submit button :
You can easily retrieve other important file variables too. The code below returns name, size and type of the file:
How about restricting file type user can upload?
The above examples shows the basic things you can do with File API, directly interact with client files without the use of alternative methods. All modern browsers should support HTML5’s File API, you can check caniuse.com for any changes. Good luck!