php一次上传多个文件

I have this piece of code <input type="file" name="image_logo" id="image_logo" /> This one will select only one file when browsed. Now there I have made another checkbox like this <input type="checkbox" name="multiple_upload" value="yes" > &nbsp; Do You want to upload multiple files at a time?

Now if someone click on the checkbox I want he can select multiple files to upload. For multiple files select I have the code like this <input type="file" name="image_logo" id="image_logo" multiple />

But here I want that if a user clicks on the checkbox then he will select multiple files at atime otherwise he will select only one file. So for that my code goes like this

<input type="checkbox" name="multiple_upload" value="yes" >
 <?php if(isset($_POST['multiple_upload'])) {
  <input type="file" name="image_logo" id="image_logo" multiple />
 }
 else {
 <input type="file" name="image_logo" id="image_logo"  />
 }

But here the problem is as I have used $_POST then he can't select all the files on click instantly. I want that when user click on checkbox then he will instantly select multiple files at a time. He don't have to refresh the page.

If the user doesn't click on checkbox then he can't select multiple files at a time. So can someone kindly tell me how to do this so that user can make the action instantly? Any help and suggestions will be really appreciable. Thanks

Try this

$('input[name="multiple_upload"]').change(function(){
    if($(this).val() == 'yes'){
        $('input[type="file"]').prop('multiple', true);
    }else{
        $('input[type="file"]').prop('multiple', false);
    }
});

Try this Example

$(document).ready(function () {
    $('input[name="multiple_upload"]').click(function () {
        if ($(this).is(":checked")) {
            $('#image_logo').attr('multiple', true);
        } else {
            $('#image_logo').removeAttr('multiple');
        }
    });
});