ludiusyan
ludiusyan

Reputation: 23

How to close the window of filePicker using javascript or any JS library?

I hava an input of uploading file.

<input type="file" name="data" id="inFile" style="display: none"/>
<button type="button" name="btn" onClick="browse()">Choose file</button>

Browser will show a popup window of choosing file when the input is clicked.

I want to close the popup window using javascript or any JS library.

var timeout;
function browse(){
    var fileElem = document.getElementById("inFile");
    fileElem.click();
    timeout = setTimeout(closeWindow, 5000);
}

function closeWindow(){
    // close filepicker window if window is opened.
}

Can it be achieved? How to do? Thanks.

I want to close filepicker window automatically.

Upvotes: 2

Views: 846

Answers (1)

Matey
Matey

Reputation: 1210

I'm afraid this might be impossible. For security purposes, the file browser dialog is invisible to JavaScript and all interaction with it must come from the user actually pressing mouse on the system dialog.

Upvotes: 2

Related Questions