mirror of
git://f0xx.org/ac/ac-platform-web
synced 2026-08-09 20:59:36 +03:00
Sync QR logo asset and app.js with platform-php updates.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1812,19 +1812,33 @@
|
||||
}
|
||||
|
||||
if (fileForm) {
|
||||
const maxAttachmentBytes = 16 * 1024 * 1024;
|
||||
fileForm.addEventListener('submit', function (e) {
|
||||
e.preventDefault();
|
||||
const fd = new FormData(fileForm);
|
||||
fd.append('ticket_id', id);
|
||||
const fileInput = fileForm.querySelector('input[type="file"]');
|
||||
const picked = fileInput && fileInput.files && fileInput.files[0];
|
||||
if (picked && picked.size > maxAttachmentBytes) {
|
||||
if (fileStatus) fileStatus.textContent = 'File too large (max 16 MiB)';
|
||||
return;
|
||||
}
|
||||
if (fileStatus) fileStatus.textContent = 'Uploading…';
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', basePath() + '/api/ticket_attachments.php', true);
|
||||
xhr.onload = function () {
|
||||
if (xhr.status === 413) {
|
||||
if (fileStatus) fileStatus.textContent = 'File too large (max 16 MiB)';
|
||||
return;
|
||||
}
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(xhr.responseText);
|
||||
} catch {
|
||||
if (fileStatus) fileStatus.textContent = 'Invalid response';
|
||||
if (fileStatus) {
|
||||
fileStatus.textContent =
|
||||
xhr.status >= 400 ? 'Upload failed (HTTP ' + xhr.status + ')' : 'Invalid response';
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!data.ok) {
|
||||
@@ -1838,7 +1852,12 @@
|
||||
if (fileStatus) fileStatus.textContent = 'Uploaded';
|
||||
};
|
||||
xhr.onerror = function () {
|
||||
if (fileStatus) fileStatus.textContent = t('reports.network_error');
|
||||
if (fileStatus) {
|
||||
fileStatus.textContent =
|
||||
picked && picked.size > 1024 * 1024
|
||||
? 'Upload failed — file may exceed server limit (max 16 MiB)'
|
||||
: t('reports.network_error');
|
||||
}
|
||||
};
|
||||
xhr.send(fd);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user