Skip to content
Advertisement

How to get all files name and size using jquery from

How to get all files name and size using jquery from

My HTML

<input type="file" id="images" multiple="multiple">
<input type="submit" id="send">

My jQuery Code

$('#send').click(function(){
var image1.name = $('#images').files[0].name;
var image1.size = $('#images').files[0].size;
alert(image1.name + ' - ' + image1.size);});

Advertisement

Answer

use files attribute from the input

$('#send').click(function(){

var files = $('#images')[0].files;

for(var i = 0; i<files.length; i++){
 console.log(files[i].name+'----'+files[i].size);
}

});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="file" id="images" multiple="multiple">
<input type="submit" id="send">
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement