mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
fix: upload progress bar not visible — collectFileNames checks FilePond instances; remove admin auth from progress poll endpoint
This commit is contained in:
@@ -15,8 +15,10 @@
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../../../bootstrap.php';
|
||||
require_once __DIR__ . '/../../../src/AdminAuth.php';
|
||||
AdminAuth::requireLogin();
|
||||
// No AdminAuth check here — this endpoint is called by client-side JS during
|
||||
// both admin and partage (student) form uploads. Access is guarded by the
|
||||
// progress token (64 bits of entropy, fresh per form render) which must match
|
||||
// a temp file that only exists during an active upload.
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
function collectFileNames() {
|
||||
const names = [];
|
||||
// Check raw <input type="file"> elements (non-FilePond or FilePond-managed with storeAsFile)
|
||||
const inputs = form.querySelectorAll('input[type="file"]');
|
||||
for (const fi of inputs) {
|
||||
if (fi.files) {
|
||||
@@ -41,6 +42,21 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
// Also check FilePond instances directly (their storeAsFile hidden inputs may not
|
||||
// have .files populated yet when the submit event fires)
|
||||
if (typeof FilePond !== 'undefined') {
|
||||
const pondInputs = form.querySelectorAll('.tfe-file-picker');
|
||||
for (const pi of pondInputs) {
|
||||
const pond = FilePond.find(pi);
|
||||
if (pond) {
|
||||
const pondFiles = pond.getFiles();
|
||||
for (const pf of pondFiles) {
|
||||
const name = pf.filename || (pf.file && pf.file.name);
|
||||
if (name) names.push(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user