html Markup:
<form action="" method="post" enctype="multipart/form-data">
<input id="fileSelect" type="file" id="file" name="files[]" multiple="multiple" accept="image/*" />
<input type="submit" value="Upload!" onclick='showFileModified();' />
</form>
Script:
<script type='text/javascript'>
function showFileModified()
{
var input, file;
input = document.getElementById( 'fileSelect' );
file = input.files[0];
file.lastModifiedDate;
alert(file.lastModifiedDate);
}
</script>
If i select more than one file lets say 4 files. i want each file modified date alert(file.lastModifiedDate). how can i use array here to achieve this.
what i tried:
function showFileModified()
{
var input[], file;
input = document.getElementById( 'fileSelect' );
for(var i=0; i<=input.length; i++)
{
alert('d');
file = input.files[i];
file.lastModifiedDate;
alert(file.lastModifiedDate);
}
}
input.filesis your array. shouldn't you check it's length rather thaninput?for(var i=0; i<=input.length; i++)input.lengthmakes no sense. You only have one input, which you selected by id, it doesn't have a length.