File manager - Edit - /home/autoph/public_html/ltms-upload/js/ltms.js
Back
var upload_image_name = []; var myDropzone; function photoDropzoneListener() { Dropzone.autoDiscover = false; // Disable auto-discovery // Initialize Dropzone const myDropzone = new Dropzone("#upload-ltms-photo", { url: "javascript:void(0);", // Prevent Dropzone's default POST autoProcessQueue: false, // Disable auto-upload acceptedFiles: '.png,.jpg,.jpeg', maxFilesize: 40, // Max file size in MB maxFiles: 10, // Max number of files clickable: true, addRemoveLinks: true, dictCancelUpload: 'Cancel', parallelUploads: 10, // Allow processing up to 10 files renameFile: function (file) { const extension = file.name.split('.').pop().toLowerCase(); return `${uniqImgId()}.${extension}`; }, init: function () { this.on("maxfilesexceeded", function (file) { alert('Only 10 images allowed.'); this.removeFile(file); return; }); this.on("error", function (file, response) { alert(response || 'Error uploading file.'); }); this.on("addedfile", function (file) { console.log(`File added: ${file.name}`); }); this.on("success", function (file, response) { console.log(`File uploaded successfully: ${file.name}`); }); this.on("queuecomplete", function () { console.log("All files in the queue have been processed."); }); }, }); // Handle Submit Button $("#ltms-submit").on("click", function (e) { e.preventDefault(); // Prevent default form submission const fullname = $("#fullname").val().trim(); if (!fullname) { Swal.fire({ title: "Warning!", text: "Fullname is required!", icon: "warning", }); return; } const queuedFiles = myDropzone.getQueuedFiles(); if (queuedFiles.length === 0) { Swal.fire({ title: "Warning!", text: "No files to upload.", icon: "warning", }); return; } // Create FormData object for batch upload const formData = new FormData(); formData.append("fullname", fullname); formData.append("cs_number", $("#cs_number").val()); // Add files to FormData queuedFiles.forEach((file) => { formData.append("files[]", file, file.upload.filename); }); // Send AJAX request $.ajax({ url: "upload.php", // Change to your backend endpoint method: "POST", data: formData, processData: false, contentType: false, beforeSend: function () { Swal.fire({ title: "Uploading...", text: "Please wait while your files are being uploaded.", allowOutsideClick: false, showConfirmButton: false, willOpen: () => { Swal.showLoading(); }, }); }, success: function (response) { Swal.close(); // Close loading alert if (typeof response === "string") { response = JSON.parse(response); } const now = new Date(); const formatter = new Intl.DateTimeFormat("en-PH", { timeZone: "Asia/Manila", year: "numeric", month: "long", day: "numeric", }); const formattedTime = formatter.format(now); var fullname = $("#fullname").val(); var csNumber = $("#cs_number").val() || "(N/A)"; // Show N/A if CS Number is not provided Swal.fire({ title: "Success!", html: `<p>Your image has been uploaded successfully.</p><br> <p><strong>Registered Name:</strong> ${fullname}</p> <p><strong>CS Number:</strong> ${csNumber}</p> <p><strong>Date:</strong> ${formattedTime}</p><br> <p><strong>Reference Code:</strong> ${response.reference}</p><br> <small><p>You can screenshot this message for your reference.</p></small>`, icon: "success", showConfirmButton: true, confirmButtonText: "Close", allowOutsideClick: false }).then(() => { // Refresh the page when the alert is closed window.location.reload(); $("#fullname").val(''); $("#cs_number").val(''); }); }, error: function (error) { Swal.close(); // Close loading alert Swal.fire({ title: "Error!", text: "An error occurred while uploading files. Please try again.", icon: "error", }); console.error(error); }, }); }); } // Generate Unique Image ID function uniqImgId() { return Math.round(new Date().getTime() + Math.random() * 100); } function removeImage(id) { Swal.fire({ icon: 'warning', html: 'Do you want to remove this image?', showDenyButton: false, showCancelButton: true, confirmButtonText: `Confirm`, denyButtonText: `Don't Confirm`, }).then((result) => { if (result.isConfirmed) { // toastr.remove(); $.ajax({ url: "api/upload/upload_image_ltms.php", method: "POST", data: { apiKey: '9434631886897744', id: id }, cache: false, beforeSend: function() { alert('info', 'Oops...', 'Removing image...'); }, success: function(data) { // fetchVehicleInfo(vehicle_record_id, customer_record_id) // readVehicleImage(vehicle_record_id); readLtmsUpload(); sweetAlertSimple('success', 'Oops...', 'Image remove successfully.'); // setTimeout(() => { // // Refresh the page or update the UI // window.location.reload(); // }, "1000"); } }) } else if (result.isDenied) { // Swal.fire('', 'Changes are not saved', 'info') } }) } // function readLtmsUpload() { // $.ajax({ // url: "api/upload/upload_image_ltms.php", // type: "POST", // dataType: 'json', // data: { // apiKey: '1164288154587287', // cuid:customer_record_id // }, // beforeSend: function() {}, // success: function(result) { // // result.total // $('#customer-ltms-image-data').html(''); // $('#customer-ltms-image-data').append(result.vehicle_image); // } // }); // } // readLtmsUpload(); photoDropzoneListener();
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0.11 |
proxy
|
phpinfo
|
Settings