I have a submit function via ajax that get values from a form via jQuery. There are multiple dropzones, which I need to grab from upon pressing the submit button for the entire form.
I can access the dropzones file objects like this:
$('#foobar')[0].dropzone.getAcceptedFiles()[0]
which gives me something like this:
File
_removeLink: <a class="dz-remove" href="javascript:undefined;" data-dz-remove="">
accepted: true
dataURL: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopG…etc"
height: 545
lastModified: 1516739363000
lastModifiedDate: Date 2018-01-23T20:29:23.000Z
name: "foobar.jpg"
previewElement: <div class="dz-preview dz-image-preview">
previewTemplate: <div class="dz-preview dz-image-preview">
size: 45960
status: "queued"
type: "image/jpeg"
upload: Object { progress: 0, total: 45960, bytesSent: 0, … }
webkitRelativePath: ""
width: 550
__proto__: FilePrototype { name: Getter, lastModified: Getter, lastModifiedDate: Getter, …
When I try to put this into an object to send to the server I get the error:
var params = {
id: $('bla).val(),
dropzone_image: $('foobar')[0].dropzone.getAcceptedFiles()[0]
}
TypeError: 'click' called on an object that does not implement interface HTMLElement.
How can I attach this dropzone file as an image/file here to send to the backend?