F
Filament16mo ago
Kleis

File upload not showing after reload

I have added a FileUpload field.
FileUpload::make('photos')
->disk('public')
->directory(function(\App\Models\Apartment $record) { return 'apartments/'.$record->name.'/photos/'; })
->preserveFilenames()
->multiple()
->reorderable()
FileUpload::make('photos')
->disk('public')
->directory(function(\App\Models\Apartment $record) { return 'apartments/'.$record->name.'/photos/'; })
->preserveFilenames()
->multiple()
->reorderable()
When I try to upload a image, it shows the progress bar correcly, then a preview of the uploaded image, when I save the page the file is stored correctly in the directory requested and the database field is updated.
-rw-r--r-- 1 semweb users 341K Aug 11 10:27 Peugeot_e-208_dynamic_front34.jpg
photos: "["apartments\/A\/photos\/\/Peugeot_e-208_dynamic_front34.jpg"]",
-rw-r--r-- 1 semweb users 341K Aug 11 10:27 Peugeot_e-208_dynamic_front34.jpg
photos: "["apartments\/A\/photos\/\/Peugeot_e-208_dynamic_front34.jpg"]",
photos is text field and has array cast in the model However when I reload the admin page the image is not shown anymore, and theres no resource failed to load in the network monitor. Any ideas ?
3 Replies
Dennis Koch
Dennis Koch16mo ago
Do you only show this field on Edit? Since $record->name will be empty on CreatePage
when I save the page the file is stored correctly in the directory requested
Seems like it isn't if you check the filepath. And this is probably your issue.
Kleis
KleisOP16mo ago
This is on the edit page yes, but good point that name wont be set on a create page. The path looks ok, except for the added forward slash, no? photos: "["apartments/A/photos//Peugeot_e-208_dynamic_front34.jpg"]", semweb@dedi5139:~/public_html/demo$ ls public/storage/apartments/A/photos/ Peugeot_e-208_dynamic_front34.jpg omg... I had a photoAttribute from before rewriting the admin panel to filament, which was stealing the database field. It works now 🫣
Dennis Koch
Dennis Koch16mo ago
Sorry. Thought the forward slash was because the name was missing. But that was further at the start
Want results from more Discord servers?
Add your server