Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

maparfitt's avatar

Uploading to S3 in production (using Filament's Spatie Media Library Plugin)

I'm using Filament and the Spatie Media Library plugin to upload images. The files are stored in S3. Everything works fine on the development site. But on the production site, I hit a filepond error about 1/3 of the way through the upload, "Error during upload." (No errors are showing in console).

The AWS credentials in env are the same on both development and production.

I've set the APP_URL correctly on production.

I've added the production site's URL to the CORS permissions on the bucket. I think the permissions must be okay otherwise, because uploads work fine from the local development site. But I'm pretty new to AWS, so I may be missing something.

I'm hosting the production site on Forge. Any idea what could be preventing uploads on the production site? Thank you!

0 likes
2 replies
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

It sounds like you've covered some of the common issues related to AWS S3 uploads, such as ensuring the AWS credentials are set correctly and configuring CORS permissions. However, since the error occurs only on the production site, here are a few steps you can take to troubleshoot and potentially resolve the issue:

  1. Check Network Issues: Since the error occurs partway through the upload, it could be a network issue. Ensure that your production server has a stable and fast internet connection to AWS S3.

  2. Verify File Size Limits: AWS S3 and your server configuration might have file size limits. Check if the production server has any limits on the file size that can be uploaded.

  3. Inspect Server Logs: Look at the server logs for any errors that might not be showing up in the console. This can give you more information about what's going wrong during the upload process.

  4. Check PHP Configuration: Ensure that the upload_max_filesize and post_max_size directives in your php.ini file are set high enough to handle the file uploads.

  5. Examine S3 Bucket Policy: Double-check the S3 bucket policy to ensure that it allows write operations from your production server.

  6. Debug with Laravel's Log: Add logging to your upload code to capture any exceptions or errors that occur during the upload process. You can use Laravel's logging facilities to write to the log file.

Here's an example of how you might add logging to your upload code:

try {
    // Your upload code here
} catch (\Exception $e) {
    \Log::error('Upload failed: ' . $e->getMessage());
    // Return an appropriate response to the user
}
  1. Check for Timeout Issues: If the upload takes a long time, it might be hitting a timeout limit. Check your server's timeout settings and consider increasing them if necessary.

  2. Update Packages: Ensure that you are using the latest versions of Filament, Spatie Media Library, and any other related packages, as updates might contain fixes for bugs that could be causing your issue.

  3. Contact Hosting Support: Since you're using Forge, there might be some server-specific configurations or restrictions that are affecting the upload process. Contacting Forge support could provide insights into any production-specific issues.

  4. Test with a Smaller File: Try uploading a smaller file to see if the issue is related to the file size or if it happens with any file.

If none of these steps resolve the issue, you might need to provide more detailed error messages or logs to get further assistance. Remember to redact any sensitive information before sharing logs or error messages on public forums.

1 like
maparfitt's avatar

Thanks, Lary. It was indeed a problem with the server. I hadn't adjusted the max upload size when I created a new server for this site. So problem solved. All good.

Please or to participate in this conversation.