0

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

  • 1
    Does this answer your question? [How to upload multiple files using PHP, jQuery and AJAX](https://stackoverflow.com/questions/19295746/how-to-upload-multiple-files-using-php-jquery-and-ajax) – Xun Jul 05 '22 at 03:02
  • Your HTML markup is not valid! The `form` must be wholly contained within a single table-cell or the entire table must be wholly contained within a single form. – Professor Abronsius Jul 05 '22 at 05:45

0 Answers0