It seems like you're having trouble with file uploads using Spatie's Media Library in combination with Filament. The error message "error during upload - tap to retry" suggests that there might be an issue with the server-side processing of the upload request.
Here are a few steps you can take to troubleshoot and resolve the issue:
-
Check the Disk Configuration: Ensure that the disk you're using for media uploads is correctly configured in
config/filesystems.php. Based on your configuration, it looks like you're using thepublicdisk. Make sure that theMEDIA_DISKenvironment variable is set topublicin your.envfile:MEDIA_DISK=public -
Permissions: Check the permissions of the
storage/app/publicdirectory. The web server should have write permissions to this directory. You can set the correct permissions using the following commands:php artisan storage:link chmod -R 775 storage/app/public chown -R www-data:www-data storage/app/publicReplace
www-data:www-datawith the appropriate user and group that your web server runs under. -
Debugging: To find out what the error is during the upload, you can check the Laravel log files in
storage/logs/. Additionally, you can open the browser's developer tools (usually F12) and check the Network tab for the request that fails. The server response might contain more details about the error. -
File Size Limit: Ensure that the file you're trying to upload does not exceed the maximum file size defined in the Spatie Media Library configuration (
'max_file_size' => 1024 * 1024 * 10). Also, check your PHP configuration (php.ini) forupload_max_filesizeandpost_max_sizeto ensure they are not limiting the file size. -
Media Collection Configuration: If you want all hobby images grouped together in a folder, you can use the
useDiskmethod on the media collection to specify a custom disk that points to a specific directory:public function registerMediaCollections(): void { $this->addMediaCollection('hobby_img') ->useDisk('media') ->useFallbackUrl('https://placeholder.co/300x300'); }Make sure to create a
mediadisk configuration inconfig/filesystems.phpif you haven't already. -
File Upload Component: Ensure that the
SpatieMediaLibraryFileUploadcomponent is correctly set up in your Filament resource. Thecollectionmethod should match the collection name you defined in your model'sregisterMediaCollectionsmethod.
If after following these steps the issue persists, you may need to provide more specific error messages or logs to further diagnose the problem.