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

2
  • 1
    Does this answer your question? How to upload multiple files using PHP, jQuery and AJAX Commented Jul 5, 2022 at 3: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. Commented Jul 5, 2022 at 5:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.