How input:file is not triggered by a click.

< input type= "file" > how to use js emulation to trigger a file selection pop-up box without clicking the trigger. (you can"t click on other elements either).

Nov.17,2021

jquery triggers
$('input'). Click ()
can also be used natively
dom = document.getElementById (''). Click ();
) or
var event = document.createEvent ('MouseEvents')
event.initMouseEvent (' click',false,false)
dom.dispatchEvent (event)


<input type="file" id="upload">

var $input = document.querySelector('-sharpupload');
$input.onclick = function() {
    console.log('a');
}
$input.click();

execute the above code in chrome, and the console will print out the contents of the console statement, but will not pop up the window that selects the file. Execute document.querySelector ('- sharpupload'). Click () ) directly in the console and the window will pop up.
there will be a message in firefox saying that a pop-up window is blocked, and if you choose allow, you will be able to pop up the window that selects the file.
this should be due to the browser's security considerations.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eabb1f-2073.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eabb1f-2073.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?