Advertisement
backlight0815

Old Dropzzone Script

Jul 22nd, 2023
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. Dropzone.autoDiscover = false;
  2.  
  3. document.addEventListener("DOMContentLoaded", function () {
  4. const myDropzone = new Dropzone("#receiptDropzone", {
  5. autoProcessQueue: false, // Disable auto-upload
  6. maxFiles: 1, // Allow only one file to be uploaded
  7. addRemoveLinks: true,
  8. renameFile: function(file) {
  9. var dt = new Date();
  10. var time = dt.getTime();
  11. return time + file.name;
  12. },
  13. // Other Dropzone options if needed
  14. init: function () {
  15. const submitButton = document.querySelector("#checkout");
  16. const form = this; // "this" refers to the dropzone instance
  17.  
  18. submitButton.addEventListener("click", function (event) {
  19. event.preventDefault();
  20. event.stopPropagation();
  21. form.processQueue(); // Process the queue manually
  22. });
  23.  
  24. // Listen for the success event when all files are uploaded
  25. this.on("success", function (file, response) {
  26. // Assuming the response contains the notification data
  27. const notification = response.notification;
  28. if (notification && notification.message) {
  29. // Display the notification message using your preferred method
  30. alert(notification.message);
  31. }
  32.  
  33. // Redirect after successful checkout
  34. window.location.href = "{{ route('success.checkout') }}"; // Replace with your success page route
  35. });
  36.  
  37. // Listen to the addedfile event to handle file upload and saving
  38. this.on("addedfile", function (file) {
  39. // Make sure to remove any previously uploaded file
  40. if (this.files.length > 1) {
  41. this.removeFile(this.files[0]);
  42. }
  43. });
  44.   },
  45.     });
  46. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement