javascript - How can I get all filenames which are uploaded via file dialog? -


i've started learning react js , problem that; want select multiple file file dialog , want display them on screen name.

<raisedbutton classname="raisedbtn" label="video ekle" onclick={this.openfiledialog}>            <input              ref={(input) => { this.textinput = input; }}              style={{"display" : "none"}}              type="file" multiple                 onchange={this.handlefilechange}              >            </input>          </raisedbutton> 

there okay.

openfiledialog(){ reactdom.finddomnode(this.textinput).click(); }

there okay again.

the problem there:

handlefilechange(e){ var files = e.target.files;  (var = 0; < files.length; i++) {   var file = files[i];   let reader = new filereader();   var filename = file.name;    reader.onload = (e) => {       tilesdata.push({img: e.target.result, title: filename})       this.setstate({image: e.target.result,  title: filename});   };  reader.readasdataurl(file);     } } 

all images name same (all of them have last selected file's name). think reader.onload running asynchronous loop go on reader.onload not finish running? how can fix it?

thanks in advance.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -