Adding More Data To Dropzone.js Post
Solution 1:
It's been a while since you asked this question but based on the dropzone website tips
http://www.dropzonejs.com/#tips
you should be able to do one of 3 things -
1. if there is a form add hidden params.
2. you can use params like so -
new Dropzone({
url: "/",
params: {
foo: "bar"
}
});
3. handle the on sending event like so -
myDropzone.on("sending", function(file, xhr, formData) {
// Will sendthe filesize along with the file as POST data.
formData.append("filesize", file.size);
});
Solution 2:
I find the tutorial you're providing a bit confusing since, indeed, there's no form involved. Simply create a form with class="dropzone"
and add hidden inputs. It only shows the default template for dropped files and some JS code for basic event handling. I recommend checking out the main Dropzone page for examples.
For instance, in our code, it looks somewhat like this (redacted a bit) :
<form action="myAction"
class="dropzone"id="dropzoneId"
name="pictures">
<input type="hidden" name="id">
</form>
And, really, that's it. We have some Javascript code to handle the hidden id
field and some fancier features but the id gets posted along with the picture data.
Solution 3:
I know this is a pretty old post but I tried to make the answer of SolarBear to work and it worked for me when adding the parameter "value" to the hidden input like this;
<formaction="/action.php"class="dropzone"><inputtype="hidden"name="additionaldata"value="valueToPass" /></form>
Thanks for your help!
Post a Comment for "Adding More Data To Dropzone.js Post"