I'm just wondering if this is actually possible, if it is not, why?
- add files via input type file multiple true
- files get stored in array of "FilesList" inside javascript
- when user is done selecting images, click upload
- upload all images in that stored array in javascript
var storedFiles = [];
$("#inputFileId").on('change', function() {
if ($(this)[0].files) {
for (var i = 0; i < $(this)[0].files.length; i++) {
storedFiles.push($(this)[0].files[i]);
}
}
});
$("#inputSubmitId").click(function() {
// add this storedFiles to an input is possible?
// like $("#input").val = storedFiles;
console.log(storedFiles);
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p>select any amount of images, how many times you want to</p>
<input type="file" multiple="true" id="inputFileId" />
<input type="submit" id="inputSubmitId" />
$(this)[0].files = storedFilesFailed to set the 'files' property on 'HTMLInputElement': The provided value is not of type 'FileList'.typeof storedFiles = objectinput type="file"control - you cannot do that. You will need to upload your aggregated file array via AJAX for this to work