ManiMuthuPandi
ManiMuthuPandi

Reputation: 1604

Laravel does not accept file while post

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

Upvotes: 0

Views: 664

Answers (1)

DarthCoder
DarthCoder

Reputation: 111

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

Upvotes: 3

Related Questions