Reputation: 594
I'm just wondering if this is actually possible, if it is not, why?
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" />
Upvotes: 0
Views: 1787
Reputation: 739
You can't upload files via js..It is an client side language...You need to use php or any cliend side language for that.... Here it is a website which includes it all:W3 Schools
Use multiple tag to get multiple images at a time and then using php store this images....
Upvotes: 1