Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve Exception Serialization of 'Illuminate\Http\UploadedFile' is not allowed?

I need help to solve this error Exception Serialization of 'Illuminate\Http\UploadedFile' is not allowed

I am using events and listeners.

I wanna save a title, description and a photo. I think , the problem is the photo!

    public function storePublication($request){
        event(new  PublicationEvent($request->all()));
    }

    class PublicationEvent implements ShouldBroadcast
    {
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $publication;
    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct($publication)
    {
        $this->publication = $publication;
    }


    class SendAutoResponder implements ShouldQueue
    {   
    /**
     * Handle the event.
     *
     * @param  PublicationEvent  $event
     * @return void
     */
    public function handle(PublicationEvent $event)
    {
        dd($event);
    }

like image 292
brian Avatar asked Sep 16 '25 06:09

brian


1 Answers

You can’t pass an uploaded file instance to a job (event). You need to write it to disk somewhere, and then retrieve it when handling the job (event). Check Serialization of 'Illuminate\Http\UploadedFile' is not allowed On queue

like image 88
Senthurkumaran Avatar answered Sep 17 '25 22:09

Senthurkumaran