Capture sent files before uploading

My goal would be to “catch” a file before it is sent to perform client-side controls. In practice I’d need to know what is the function that is invoked after you choose the file to upload.

I’m working on the web client and the idea would be to intercept the file to upload, make changes, and upload it. Eg. convert a file before uploading.

There is an upload function that takes raw data and take care to load them?
If it exists, where it is invoked??
If it is possible i prefer work only on client-side javascripts.

I thank everyone in advance, greetings.