Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

237
Views
ajax attachment multiple file in chat but only send one file

i have html

<div data-role="content">
    <div class="main-content">
        <p>Your Name: <span id="name" class="nickname"></span></p>
        <div id="chat"></div>
        <br>
        <input type="file" name="file[]" id="file" multiple>
        <br>
        <input type="text" data-clear-btn="true" id="msg">
    </div>
</div>

and script

function send() {
msg = $("#msg").val();
if(msg.trim() == "") { $("#msg").val(""); return; }
//
        var files = [];
        var input = document.getElementsByName('file[]');
        for (var i = 0; i < input.length; i++) {
            var a = input[i];
            files = files + "files[" + i + "] = " + a.value + ", ";
        }
    //
$.ajax({
    url: "ajax-server.php",
    type: "POST",
    data: { action: "send", name: $("#name").text(), msg: msg, files: files },
    success: function(r) {
        $("#chat").html(r).scrollTop($('#chat')[0].scrollHeight);
        $("#msg").val("");
        $("#file").val("");
    },
});}

original code only send text chat, i added multiple file attachment. but code only send one file. how i change code to send multiple file. plz help, thanks all!

i added file attachment

enter image description here

But only send one file

enter image description here

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!