Nihir's avatar
Level 50

Laravel filament pdf Upload error

Hi Everyone I faced some issues with filament file upload I'm new to the filament. So in my case, I have two fields one is thumbnail_iimg & the second one is pdf. Both are stored in different folders called thumbnail_img stored in thumbnail folder & pdf stores in catalogs stores my env APP_URL is http://127.0.0.1:8000 & storage has already been linked but whenever I try to upload the pdf it display an error called Error During Upload & i check the console so it displayed that *** POST-http://127.0.0.1:8000/livewire/upload-file?expires=1685421046&signature=3b012670fa4bf9f25ff78e18c72036ec837f2e7be1df91074c9d03b3a85daf7f 422 (Unprocessable Content) UploadManager.js:131 ***

Please help me to solve this error & I can not upload the pdf

0 likes
5 replies
LaryAI's avatar
Level 58

The error message "422 (Unprocessable Content)" usually indicates that the server was unable to process the request due to invalid data. In this case, it could be due to a validation error or an issue with the file itself.

To troubleshoot this issue, you can try the following steps:

  1. Check the server logs for any error messages related to the file upload.
  2. Verify that the file size and type are within the limits set by your application.
  3. Check the Livewire component responsible for handling the file upload to ensure that it is properly configured.
  4. Try uploading a different file to see if the issue persists.

If none of these steps resolve the issue, you may need to seek further assistance from the Laravel Filament community or consult the documentation for more information.

Example code:

// Example Livewire component for handling file uploads
class UploadFile extends Component
{
    public $pdf;

    public function save()
    {
        $this->validate([
            'pdf' => 'required|mimes:pdf|max:2048',
        ]);

        $path = $this->pdf->store('catalogs');

        // Save the file path to the database or perform other actions
    }

    public function render()
    {
        return view('livewire.upload-file');
    }
}
Nihir's avatar
Level 50

@LaryAI Hi You suggest me well but the thing is my project is in filament so there is some difference on it let me know if you have any other suggestion

joemardevs's avatar

I have the same error for file upload, by any chance can you share the solution if you already solve it. Thanks

joemardevs's avatar
Level 1

@joemar Already found a solution, its the upload_max_filesize in the php.ini.

2 likes

Please or to participate in this conversation.