I'm trying to upload a file with one click.
I can select the file, but just can't get it to upload to a specific location on the server with one click. Need help with the remainder.
Html:
<form>
<input type="file" id="real-file" class="displaynone"/>
<button id="custom-button" class="button-input-3">Upload file</button>
</form>
JS:
<script type="text/javascript">
const realFileBtn = document.getElementById("real-file");
const customBtn = document.getElementById("custom-button");
customBtn.addEventListener("click", function() {
realFileBtn.click();
});
</script>
My apologies. I'm relatively new to this and feeling my way. Any assistance you can provide would be greatly appreciated. Thanks.
onchangeevent to the file input, and do the submission there.