How can I validate if the user has selected a file to upload?
Edit: bumped
Simple and powerful way(dynamic validation)
place formats in array like "image/*"
var upload=document.getElementById("upload"); var array=["video/mp4","image/png"]; upload.accept=array; upload.addEventListener("change",()=>{ console.log(upload.value) })