Input type=File "Accept" property does not work in Chrome? Input type=File "Accept" property does not work in Chrome? google-chrome google-chrome

Input type=File "Accept" property does not work in Chrome?


Since this post has an active bounty I can't flag it for duplicate but I would strongly recommend you to read this other stackoverflow post on the same exact topic. I think it provides the right ammount of information for your problem. Cheers!


I am agree with @Eugenio comment. You can validate it at client-side and server-side.

if you use accept="image/*" instead Custom Files it will show Image Files

enter image description here

 function validate() {  var fileName = document.getElementById("fileType").value;  var dot = fileName.lastIndexOf(".") + 1;  var extFile = fileName.substr(dot, fileName.length).toLowerCase();  if (extFile == "jpg" || extFile == "jpeg") {   //accepted  } else {   alert("Only jpg and jpeg image files allowed!");  } }
<input type="file" id="fileType" accept="image/*" onchange="validate()"/>