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

209
Views
Jquery drag n drop files without ajax

i made a script for drag and drop a file and upload when submit that script works thanks to Ajax, but i want it without using ajax and so without e.preventDefault(); just like a normal post form... how i should edit it?

    form.submit(function (e) {
        e.preventDefault();

        let formData = new FormData(this);
        
        for (let i = 0; i < filesLoader.length; i++) {
            formData.append(filesLoader[i][0], filesLoader[i][1])
        }

        $.ajax({
            type: form.attr('method'),
            url: form.attr('action'),
            data: formData,
            enctype: 'multipart/form-data',
            cache: false,
            contentType: false,
            processData: false,
            success: function (data) {
                console.log("Success")
            },
            error: function (data) {
                console.log("error")
            },
        });
    });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

found the solution, on Drop function i change input field too with fileField.prop("files", e.originalEvent.dataTransfer.files); thanks to this works for both normal submit or by ajax

        dndFileArea.on('drop', function (e) {

            let file = e.originalEvent.dataTransfer.files;
            fileField.prop("files", e.originalEvent.dataTransfer.files);
            filesLoader.push([fileField.attr("name"), file[0]]);
about 4 years ago · Juan Pablo Isaza Report
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!