Xavier P. answered 03/14/19
Creatively Open-minded tutor in Programming, Math and The Arts
You can add a click event to a file input event. However, you will get a mouse event, which fires before you select a file to upload. If you wanna get a file upload, you are better off using the "onchange" event so it fires when the file is chosen. You also need to wrap any code you are using to manipulate the DOM in a window onload event or document onload event or the code will not work properly. This is due to the fact that you have to wait for the document to finish creating all the html elements or you won't have any elements to add events too!
You can view a working example of the code here: https://jsfiddle.net/d82x6pwo/11/