So currently my site consists of a text input field, and I want a file browser to trigger as soon as I focus on it. The user then chooses a file, puts text in the textinput, then presses submit to upload.
My current HTML:
<input type="text" placeholder="upload" class="card" id="upload">
<br>
<div class="enter" id="submit-upload">upload</div>
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" name="submit">
</form>
The problem is that I can't find a way to fire the file browser up. I've tried quite a lot of ways, ranging from .click() to s, putting the textinput inside the form, and many ways of hiding the fileinput.
But I just can't seem to trigger the file input at all.
Is this a browser/security thing? Because all I can find that isn't blocked by security features is overlaying the button over the textinput, which doesn't really work in my case.
Any clue?