function infoAggiornate(e) { swal({ type: 'success', text: e, timer: 1500, timerProgressBar: true, showConfirmButton: false }) }; Dropzone.autoDiscover = false; document.addEventListener("DOMContentLoaded", function() { if (document.getElementById("dropzone")) { var dropzoneUploadImmaginiIntervento = new Dropzone("#dropzone", { url: "https://www.premiopiubellezzainvalle.it/assets/ajax/upload-immagini-candida-il-tuo-intervento.php", paramName: "file", maxFilesize: 2, maxFiles: 10, acceptedFiles: "image/*", addRemoveLinks: true, dictDefaultMessage: "Trascina qui le immagini o clicca per caricarle", dictMaxFilesExceeded: "Puoi caricare al massimo 10 file!", init: function () { this.on("thumbnail", function(file) { if (file.width < 3000 && file.height < 3000) { this.removeFile(file); swal({ text: "L'immagine \"" + file.name + "\" deve avere una larghezza o un'altezza minima di 3000 pixel.", type: "error", showConfirmButton: true }); } }); } }); dropzoneUploadImmaginiIntervento.on("removedfile", function(file) { fetch("https://www.premiopiubellezzainvalle.it/assets/ajax/delete-immagine-candida-il-tuo-intervento.php", { method: "POST", body: JSON.stringify({ filename: file.name }), headers: { "Content-Type": "application/json", "Accept": "application/json" } }) .then(response => response.json()) .then(data => { if (data.success) { console.log("File rimosso con successo:", file.name); } else { console.error("Errore nella rimozione del file:", data.error); } }) .catch(error => console.error("Errore nella richiesta di rimozione:", error)); }); } }); Dropzone.autoDiscover = false; document.addEventListener("DOMContentLoaded", function() { var dropzoneElem = document.getElementById("dropzone-segnalaci-cose-belle"); if (dropzoneElem) { var dropzoneUploadImmaginiIntervento = new Dropzone("#dropzone-segnalaci-cose-belle", { // URL di default (può rimanere quello delle immagini o vuoto) url: "https://www.premiopiubellezzainvalle.it/assets/ajax/upload-immagini-dropzone-segnalaci-cose-belle.php", paramName: "file", maxFilesize: 2, maxFiles: 10, acceptedFiles: "image/*,application/pdf,.doc,.docx,.odt,.rtf,.txt", addRemoveLinks: true, dictDefaultMessage: "Trascina qui i file o clicca per caricarli
Immagini, PDF, Word (Max 10 file)", dictMaxFilesExceeded: "Puoi caricare al massimo 10 file!", init: function () { var self = this; self.on("thumbnail", function(file) { // Verifichiamo se è un'immagine if (file.type.match(/image.*/)) { // Controllo dimensioni if (file.width < 3000 && file.height < 3000) { // Rimuoviamo il file se non rispetta i criteri self.removeFile(file); swal({ text: "L'immagine \"" + file.name + "\" deve avere una larghezza o un'altezza minima di 3000 pixel.", type: "error", confirmButtonText: "OK" }); } else { // Dimensioni OK: impostiamo l'URL specifico per le immagini self.options.url = "https://www.premiopiubellezzainvalle.it/assets/ajax/upload-immagini-dropzone-segnalaci-cose-belle.php"; } } }); self.on("processing", function(file) { // Se non è un'immagine, gestiamo l'URL per i documenti qui // (dato che per i file non-immagine l'evento thumbnail non scatta) if (!file.type.match(/image.*/)) { self.options.url = "https://www.premiopiubellezzainvalle.it//assets/ajax/upload-documenti-dropzone-segnalaci-cose-belle.php"; } }); // 3. RIMOZIONE FILE self.on("removedfile", function(file) { if (file.status === Dropzone.SUCCESS) { // Qui potresti voler aggiungere una logica simile se anche la cancellazione // avviene su file diversi a seconda del tipo fetch("https://www.premiopiubellezzainvalle.it/assets/ajax/delete-immagine-candida-il-tuo-intervento.php", { method: "POST", body: JSON.stringify({ filename: file.name }), headers: { "Content-Type": "application/json" } }) .then(response => response.json()) .catch(error => console.error("Errore rimozione:", error)); } }); } }); } }); $("#input-date-start").flatpickr({ locale: "it", dateFormat: "d/m/Y" }); $("#input-date-end").flatpickr({ locale: "it", dateFormat: "d/m/Y" }); if ($("#formPartecipa").length > 0) { // needs for recaptacha ready grecaptcha.ready(function () { // do request for recaptcha token // response is promise with passed token $('#formPartecipa').parsley().on('form:error', function () { swal({ text: "