Home > Net >  Laravel does not accept file while post
Laravel does not accept file while post

Time:07-07

I am uploading file from front end (React or Postman) to Laravel API. I try to print all the parameters received from front end as below. I have set the Content-Type : multipart/form-data in both UI and postman.

dd( $request->all() );

File value is always empty. Is there any I am missing. Attached is the postman sample. Seems like some configuration issue at Laravel API. Unable to find that. enter image description here

CodePudding user response:

I don't know which version of Laravel you're running but the $request class has a built-in method called file in which you pass the name. So, maybe this works dd( $request->file('files') ).

Here's the documentation link: https://laravel.com/docs/9.x/requests#retrieving-uploaded-files

  • Related