Laravel发布时不接受文件

发布于 2025-02-13 08:47:20 字数 394 浏览 0 评论 0原文

我正在将文件从前端(React或Postman)上传到Laravel API。我尝试打印从下一端收到的所有参数。我已经在UI和Postman中设置了content-type:Multipart/form-data

dd( $request->all() );

文件值始终为空。有我缺少的吗?附件是邮递员样本。似乎在Laravel API上的某些配置问题。找不到。

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

人海汹涌 2025-02-20 08:47:21

我不知道您正在运行哪个版本的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 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文