We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The issue
dictUploadCanceled
form-handler.js
Dropzone.options.dropper = { paramName: "file", acceptedFiles: ".jpg, .png, .ico", addRemoveLinks: true, autoProcessQueue: false, chunking: true, forceChunking: true, url: "/upload", uploadMultiple: false, maxFiles: 1, maxFilesize: 1024, // megabytes chunkSize: 1000000, // bytes dictDefaultMessage: 'Drop files here to upload. <i class="fa-solid fa-cloud-arrow-up"></i>', dictCancelUpload: "Cancel Upload", dictCancelUploadConfirmation: "Are you sure you want to cancel this upload?", dictUploadCanceled: "Upload canceled", dictResponseError: "Server responded with {{statusCode}} code.", dictRemoveFile: "Remove", init: function() { var myDropzone = this; this.on('error', function(file, errorMessage) { if (file.accepted) { var mypreview = document.getElementsByClassName('dz-error'); mypreview = mypreview[mypreview.length - 1]; mypreview.classList.toggle('dz-error'); mypreview.classList.toggle('dz-success'); } }); this.on('sending', function(data, xhr, formData) { emailElem = document.querySelector('input[type=email]') formData.append("email", emailElem.value) }) this.on('canceled', function(file) { return this.emit("error", file, this.options.dictUploadCanceled); //this doesn't display anything }) this.on("addedfile", function(file) { var removeLink = file.previewElement.querySelector(".dz-remove"); removeLink.addEventListener("click", function(e) { console.log(myDropzone.UPLOADING); //prints undefined e.preventDefault(); e.stopPropagation(); if (file.status === myDropzone.UPLOADING) { console.log("Uploading..."); myDropzone.cancelUpload(file); } else { myDropzone.removeFile(file); } }); }); const btn = document.querySelector("button[type=submit]"); btn.addEventListener("click", function(e) { e.preventDefault(); e.stopPropagation(); if (confirm("Please, press OK if you have selected a relevant file for upload.") == true) { myDropzone.processQueue(); } else { alert("Please select relevant file for upload.") } }) }, success: function(file, response) { const alertString = `<div class="alert alert-danger mt-4 mx-5 py-2 text-center fw-bold" role="alert">Success message</div>` const parser = new DOMParser(); const doc = parser.parseFromString(alertString, "text/html"); const alertElem = doc.querySelector('div') document.body.insertAdjacentElement("afterbegin", alertElem) return file.previewElement.classList.add("dz-success"); }, canceled: function(file) { return this.emit("error", file, this.options.dictUploadCanceled); } }
This is the form if necessary:
<div class="container p-3"> <form class="py-3 " action="/upload" method="post" id="" enctype="multipart/form-data"> <div class="mb-2"> <input class="form-control" type="email" name="email" id="" value="Email"> </div> <div class="dropzone dz-clickable" id="dropper"> <!-- Dropzone --> </div> <button class="btn btn-primary" type="submit">Upload</button> </form>
Screenshots
As shown in the terminal, dropzone uploads the file to the backend despite cancelling.
The text was updated successfully, but these errors were encountered:
Enhance chunk upload cancellation handling
6a2505b
No branches or pull requests
The issue
dictUploadCanceled
does not display the supposed text to show after cancellingform-handler.js
This is the form if necessary:
Screenshots
As shown in the terminal, dropzone uploads the file to the backend despite cancelling.
The text was updated successfully, but these errors were encountered: