Hussein
Hussein
FFilament
Created by Hussein on 3/20/2025 in #❓┊help
Order of the files in File Upload is not honored
I just saw there's already an open issue for this bug, so I don't think this post makes much sense in the help forum anymore. Sorry for not checking that earlier—I thought it was a config issue on my end. Thanks for the help, @toeknee . We'll set MaxParallelUpload to 1 for now and I'll check if I can contribute with a PR. https://github.com/filamentphp/filament/issues/15308 Edit: I made my first PR 🥳. Hoping all is good https://github.com/filamentphp/filament/pull/15923
8 replies
FFilament
Created by Hussein on 3/20/2025 in #❓┊help
Order of the files in File Upload is not honored
Hi, sorry for the late reply. In our case, the users upload lot of images at time, so it is not practical for us to have them get on one by one. I tried the hook afterStateUpdated and reorderUploadedFilesUsing but with no luck. AfterStateUpdated doesn't seem to log when the user reorder or delete the images in the field, only when uploads a new image. And reorderUploadedFilesUsing only triggers once the user save the resource and with the files already ordered in wrong way. I also tried to get the order via Alpine extraAttributes, with no lucl. Only fires on uploading new files, not on reordering.
FileUpload::make('gallery')
->label('Gallery')
->image()
->multiple()
->appendFiles()
->maxSize(51200)
->reorderable()
->maxParallelUploads(5)
->storeFileNamesIn('order')
->live()
->afterStateUpdated(
function (callable $set, $state) {
Log::info('State updated:', ['state' => $state]);
}
)
->reorderUploadedFilesUsing(
function (array $state, callable $reorder): array {
Log::info('Images reordered:', ['new_order' => $state]);
return $reorder($state);
}
)
->extraAttributes([
'x-init' => '
$watch("state", (newState, oldState) => {
console.log("New State", newState);
console.log("Old State", oldState);

});
',
]),
FileUpload::make('gallery')
->label('Gallery')
->image()
->multiple()
->appendFiles()
->maxSize(51200)
->reorderable()
->maxParallelUploads(5)
->storeFileNamesIn('order')
->live()
->afterStateUpdated(
function (callable $set, $state) {
Log::info('State updated:', ['state' => $state]);
}
)
->reorderUploadedFilesUsing(
function (array $state, callable $reorder): array {
Log::info('Images reordered:', ['new_order' => $state]);
return $reorder($state);
}
)
->extraAttributes([
'x-init' => '
$watch("state", (newState, oldState) => {
console.log("New State", newState);
console.log("Old State", oldState);

});
',
]),
8 replies
FFilament
Created by Hussein on 3/20/2025 in #❓┊help
Order of the files in File Upload is not honored
So, in this case, the issue would be with FilePond, right? And would there be a way to save the initial order somewhere (another property, state, or variable) before the model is saved?
I mean, visually, we have the correct order. If I could store it and then reorder the images in the observer, that could be a possible solution.
8 replies