<input type="file" name="upload_img[]" id="upload_img" onChange="load_image()" required="required" accept="image/x-png, image/jpeg" multiple="" />
<img id = "img_File1"/>
<input type="file" style="" id="File1" />
<img id = "img_File2"/>
<input type="file" style="" id="File2" />
If you select multiple (2) images from the first file selection, Next, you want to separate the selected images in File1 and File2 and store the information respectively.
function upload_Image(){
/** File check **/
var fileCheck = "";
var fileCnt = 0;
var img = $('#upload_img[type=file]').get(0);
for (var x = 0; x < img.files.length; x++) {
fileCnt++;
}
if($("#img_Chk").val() == "Y" && fileCnt > 0) {
$("#fileCnt").val(fileCnt);
for(var i = 0; i < fileCnt; i++)
{
// Store file information separately
$("#"+"File"+i+1).val(img.files[i]);
}
}
If you want to hand over the data that <input type="file">
has, try FileReader
instead of .val()
.
https://developer.mozilla.org/ko/docs/Web/API/FileReader/readAsDataURL
© 2024 OneMinuteCode. All rights reserved.