Upload field saves as a array after saving 2 times without changing anything

So when when saving the first time, it stores it correctly, like article_images/20250428_123231.jpg however, when I save it again, without changing anything about the resource, it gets stored like {"effa7623-0b08-4e64-9c1a-0449cb63e866":"article_images\/20250428_123231.jpg"} the code I have for the file uploader is
FileUpload::make('image')
->disk('public')
->directory('article_images')
->visibility('public')
->acceptedFileTypes(['image/*'])
->preserveFilenames()
->image()
->imageEditor()
->getUploadedFileNameForStorageUsing(
fn (\Illuminate\Http\UploadedFile $file): string => (string) str_replace(' ', '', $file->getClientOriginalName())
)
->columnSpanFull(),
FileUpload::make('image')
->disk('public')
->directory('article_images')
->visibility('public')
->acceptedFileTypes(['image/*'])
->preserveFilenames()
->image()
->imageEditor()
->getUploadedFileNameForStorageUsing(
fn (\Illuminate\Http\UploadedFile $file): string => (string) str_replace(' ', '', $file->getClientOriginalName())
)
->columnSpanFull(),
I have a custom saving function created as well, however, I can't share this becuase of work policy (and this is still generic enough for it to be fine) is there a known reason why it is being turned into a array after saving it when nothing is changed? Maybe I am doing something wrong? I could not find a lot about this issue. Thanks in advance!
Solution:
Update on this, it seems that the boss man was able to figure it out. Thanks for the help!!...
Jump to solution
3 Replies
toeknee
toeknee2w ago
Not by default, if you haven't enabled multiple then it shouldn't? But multiple does need model casting to array https://filamentphp.com/docs/3.x/forms/fields/file-upload#uploading-multiple-files
FinnT730
FinnT730OP2w ago
I do not have a multiple upload. it might be the custom saving I am doing though... I will come back on that
Solution
FinnT730
FinnT7307d ago
Update on this, it seems that the boss man was able to figure it out. Thanks for the help!!

Did you find this page helpful?