Select a file by clicking on the image? (not with browse button)

Is it possible to show the "select file" window when I click on some image? I want to hide this enter and browse button that appears when I type thanks

+3
source share
2 answers

Long answer : Yes, you absolutely can. Get ready for some Javascript / CSS haxx that I prepared. Javascript first:

function getFilePathFromDialog() {
    document.getElementById('fileBrowser').click();
    document.getElementById('filePath').value = document.getElementById('fileBrowser').value;
}

Now HTML:

<img src="path/to/image.jpg" onlick="getFilePathFromDialog();">
<input type="text" id="filePath" name="filePath" /><br />
<input type="file" id="fileBrowser" name="fileBrowser" style="visibility:hidden; display:none;" />

. , . "", "filePath".

+8

, - . Flash Java.

-5

Source: https://habr.com/ru/post/1716881/


All Articles