Jari Flederick Jari Flederick - 2 days ago 3
Javascript Question

Dropzone send empty

I have a dropzone setup with the following script:

Dropzone.options.myDropzone = {
url: 'assets/PHP/createNieuws.php',
autoProcessQueue: false,
uploadMultiple: true,
parallelUploads: 1,
maxFiles: 1,
maxFilesize: 1,
acceptedFiles: 'image/*',
addRemoveLinks: true,
createImageThumbnails: true,
init: function () {
dzClosure = this; // Makes sure that 'this' is understood inside the functions below.

this.on("success", function (file, responseText) {

// for Dropzone to process the queue (instead of default form behavior):
document.getElementById("submit").addEventListener("click", function (e) {
// Make sure that the form isn't actually being sent.
if (dzClosure.getQueuedFiles().length > 0) {
} else {
dzClosure.uploadFiles([{ name: 'nofiles' }]); //send empty

//send all the form data along with the files:
this.on("sendingmultiple", function (data, xhr, formData) {
formData.append("titel", jQuery("#titel").val());
formData.append("artikel", jQuery("#artikel").val());

And i also have a file named default.png on my server. I would like dropzone to refer to default.png if no image is detected. As you can see i've tryed this solution already to no succes: https://stackoverflow.com/a/41044001/6396380

This returns the following error in my chrome console:

dropzone.js:1497 Uncaught TypeError: Cannot read property 'filename' of undefined

My dropzone version is 5.1.0 .

Any idea's on how to fix this?


This happens because the new version assumes that there is a file.upload object with filename. Changing your mock file to

{ name: 'nofiles', upload: { filename: 'nofiles' } }

should do the trick.

You should also upgrade to 5.1.1 because it solves a bug related to this.