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

90
Views
Pass file through ajax with nodejs
    const editProductBody = document.querySelector('#update-product-modal .modal-body')
    $.get({
        url: '/admin/product/detail/' + productId,
        contentType: 'multipart/form-data',
        success: function(response) {
            editProductBody.innerHTML = `
                <form action="/admin/product/update/${response._id}?_method=PUT" method="POST">
                    <label for="">Product name<span style="color: red;">*</span></label> <br>
                    <input type="text" name="name" value="${response.name}"><br>
                    <label for="">Price<span style="color: red;">*</span></label> <br>
                    <input type="text" name="price" value="${response.price}"><br>

                    <label for="">Pictures<span style="color: red;">*</span></label> <br>
                    <div class="row">
                        <div class="col-sm-9 ml-auto">
                            <img src="${response.photo[0]}"> <br>
                            <img src="${response.photo[1]}"> <br>
                        </div>
                        <div class="col-sm-3 ml-auto"> 
                            <input type="file" class="form-control" name="image1" id="image1">
                            <input type="file" class="form-control" name="image2" id="image2">
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                        <button id="btn-update-product" class="btn btn-primary">Update</button>
                    </div>
                </form>`
        }
    })

When I req.body, it has image1, image2 but I want to transfer them as files to process with cloudinary. How can I fix it ?

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!