javascript - Assign multiple images (files) from one file input to another file input(s) - upload -
i have successful upload code works perfect using ajax when select each file upload dialog. each upload has own form , input file (button upload) seen below. current code uploads files sequentially user can select more 1 photo but not together & use queuing algorithm settimeout in javascript check if first upload finishes start second upload, third, , on.
<form id="form1"> <input type="file" id="userfile1" name="userfile[]" multiple/> </form> <form id="form2"> <input type="file" id="userfile2" name="userfile[]" multiple/> </form> . . .
the problem now, when select multiple images upload (let's 2 images using ctrl), using first input file, them in array:
document.getelementbyid('userfile1').files;
so now, how can assign second image selected second input file
userfile2
because want resume upload before? not working me , read there security concerns update input file, need assign user selected, not path.
i don't want use fromdata ajax lead change code , not compatible browsers code.
thanks lot help!
it not possible assign file
object input type="file"
element using javascript
. file
object should selected user. possible select single or mutiple file
objects filelist
returned multiple
file
selection , send selected file server separate process
document.queryselector("input[name=files]") .addeventlistener("change", function(event) { var files = array.prototype.slice.call(event.target.files), filtered = []; (var = 0; < files.length; i++) { if (i > 0) filtered.push(files[i]) }; if (filtered.length) { console.log(files, filtered); filtered.foreach(function(file) { // stuff }) } })
<input name="files" type="file" accept="image/*" multiple="true" />
the problem now, when select multiple images upload (let's 2 images using ctrl), using first input file, them in array
note, filelist
object returned multiple files being selected not array
.
see input file array javascript/jquery , trigger click on input=file on asynchronous ajax done() , simulate drop file event
Comments
Post a Comment