Azy Kumbara
Azy Kumbara

Reputation: 1

how to upload multiple images at once using php ajax

Help me please, I made several input type files in a table and wanted to upload them at once using php ajax.

HTML form

<form enctype="multipart/form-data">  
     <tr>
        <td>1</td>
        <td><img src='dist/img/qr_code.png' style='width: 30px; height: 30px'/></td>    
        <td>500</td>        
        <td>sukasari</td>   
        <td>Hak</td>
        <td><input type='file' class='qr_input_file' id='qr_upload_file' name='qr_upload_file_hidden[]'/></td>
     </tr>                              
</form>
<button type="button" id="btnSimpan_qr" class="btn btn-info">Simpan</button>

ajax file

$(document).ready(function () {
  $("#btnSimpan_qr").click(function() { 
    
    var data = new FormData();
    var upload_qr = $('name=["qr_upload_file_hidden"]').prop('files')[0]['name'];

    data.append('upload_qr ',upload_qr )
                
    $.ajax({
        url: 'proses_form/proses_simpanqr.php',
        type: 'POST',
        data: data,
        processData: false,
        contentType: false,                 
        dataType: "json",       
    });
  });
});

php file

<?php
    $upload_qr_array = $_FILES['qr_upload_file_hidden']['name'];    
    $tmp_upload_qr_array = $_FILES['qr_upload_file_hidden'] ['tmp_name'];
?>

I have add

var upload_qr = $('name=["qr_upload_file_hidden"]').prop('files')[0]['name'];

in ajax file before send to php, but wrong

any suggestions what code I should write. Thank You Very Much

Upvotes: 0

Views: 187

Answers (0)

Related Questions