I need to know the number of files that an input file has in a js script, I need to do it with document.getelementbyid for my project the code is as follows but it returns me undefined
function contarImgs() {
alert(document.getElementById('imagen').files.lenght);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form action="#">
<input type="file" id="imagen" name="imagen[]" onchange="contarImgs()" multiple>
</form>
You have a typo in
length
With Jquery example: