I am coding a website where i need to get a PDF, JPG or PNG from a user. When the user choose a file i want the name of the file to be shown. Furthermore I want to check if the file is a PDF, JPG or PNG instantly so the file cant be uploaded if it isn't such a file.
My code:
<style>
#file { display:none; }
</style>
<label for="file">
<div id="file-wrapper">
<input id="file" type="file" name="file" required/>
<div class="button smallbtn">Choose file</div>
<div id="filev">No file chosen</div>
</div>
</label>
<script>
setInterval(function(){
document.getElementById("filev").innerHTML = document.getElementById("file").value;
}, 2000);
</script>