how to make uploaded image only visible inside the filament admin panel

I have a filament form outside the admin panel where fotos can be uploaded. What do i have to do that the photos are not public visible, but only from INSIDE the Admin Panel? If i put it to 'public' disk, the image is accesible via public url. And i can see it the filament admin panel. If i put it to 'local' disk, the file is not appearing in the filament admin panel.
10 Replies
awcodes
awcodes2y ago
FileUpload::make('attachment')
->disk('local')
->directory('whatever')
->visibility('private')
FileUpload::make('attachment')
->disk('local')
->directory('whatever')
->visibility('private')
visibility private, maybe?
Falk Maria Zeitsprung
i have tried that. But the filename appears in grey and it doesn't load it.
awcodes
awcodes2y ago
What do you mean it appears in gray.?
Dan Harrin
Dan Harrin2y ago
youre probably loading the file incorrectly you only need to pass in the file name to fill(), not the whole URL console errors will probably tell you whats wrong
Falk Maria Zeitsprung
Thanks very much for your answers @awcodes and @Dan Harrin Here all details: I have a external form (not in admin panel) where unregistered users can upload a Photo. Then in the Filament Admin Panel i want to see/edit the photo. I use the same code for both upload fields (in the two forms). I use this filesystems.php config 1. sreenshot I use this code in my external form and in the admin panel form: 2. sreenshot Uploaded image in external form builder form. 3. sreenshot dd of uploaded imagename 4. sreenshot Proof that image is in local file system 5. screenshot and 6. sreenshot: the grey field instead of the image in the form in the admin panel. Any idea how i could resolve that? I want the image only be visible in the admin panel (loged in admin user) and not via url from external . Thanks for any help.
Dan Harrin
Dan Harrin2y ago
check console errors on the form that doesnt show images properly
Falk Maria Zeitsprung
console error: Failed to load resource: the server responded with a status of 404 ()
Dan Harrin
Dan Harrin2y ago
send the URL its trying to fetch check the network tab
undercode
undercode2y ago
I think you have to use a temporary url to access files from not public disk.
Forms\Components\FileUpload::make('path')
->disk('private')
->directory('attachments')
->getUploadedFileNameForStorageUsing(function (TemporaryUploadedFile $file): string {
return (string) str($file->hashName());
})
->enableOpen()
])
Forms\Components\FileUpload::make('path')
->disk('private')
->directory('attachments')
->getUploadedFileNameForStorageUsing(function (TemporaryUploadedFile $file): string {
return (string) str($file->hashName());
})
->enableOpen()
])
Nils Domin
Nils Domin11mo ago
I also have a problem with private file visibility: I need to have file access only for authorized users, too. If I set the disk to 'local' and visibility to 'private', the file is saved correctly, but I can't open it with an 404 error. filesystems.php has not changed from my side. Have I missed something?
No description
No description
No description
No description
Want results from more Discord servers?
Add your server