Laravel发布时不接受文件
我正在将文件从前端(React或Postman)上传到Laravel API。我尝试打印从下一端收到的所有参数。我已经在UI和Postman中设置了content-type:Multipart/form-data
。
dd( $request->all() );
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道您正在运行哪个版本的Laravel,但是
$ request
类具有一个名为file
的内置方法,其中您传递了名称。因此,也许这可以工作dd($ request-> file('files'))
。这是文档链接: https://laravel.com/docs/9 .x/requests#retrieving-uploaded-files
I don't know which version of Laravel you're running but the
$request
class has a built-in method calledfile
in which you pass the name. So, maybe this worksdd( $request->file('files') )
.Here's the documentation link: https://laravel.com/docs/9.x/requests#retrieving-uploaded-files