javascript - Get the files chosen using the input type file (multiple) and store them in an array -
in html select multiple files.
<input type="file" id="img" multiple>
i want store each element in array can print file source.
i have done in javascript not work.
function loadfiles() { var x=document.getelementbyid("img"); (var i=0;i<x.length;i++) { document.write(x.elements[i].src); } }
the property files
gets array of files selected file input. loadfiles function should modified following:
function loadfiles() { var imagefiles = document.getelementbyid("img"), fileslength = imagefiles.files.length; (var = 0; < fileslength; i++) { document.write(imagefiles.files[i].name); } }
Comments
Post a Comment