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

Popular posts from this blog

php - Passing multiple values in a url using checkbox -

compilation - PHP install fails on Ubuntu 14 (make: *** [sapi/cli/php] Error 1) PHP 5.6.20 -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -