phpcodeigniterfile-uploaddropzone.js

Dropzone: Submit both form data and dropzone at once


I know there some questions like this, but they didn't answer questions exactly.

This is what I need,

  1. Upload files using Dropzone
  2. Save form data and uploaded image paths to DB

The problem is, How can I send both form data and dropzone files at the same time, like in the following official doc article.

I followed this Dropzone official docs Combine normal form with Dropzone

I tried this article and it worked. I could able to get both form data and files.But in this, the whole form is a Dropzone. I just need to make a Dropzone using a div.

Then I tried this approach,

I'm hoping you guys can help me out to solve this. Thank you


Solution

  • myDropzone.on("sending", function(file, xhr, formData) { 
    
     formData.append("fieldname1", $('field-name-1').val());  
    
    });
    

    You could probably even automate this and do an $.each with every input of a #form but the basic logic is above.

    The juist of this is outlined in the docs under the tab tips.