Multer给出了表单错误的未端末端

发布于 2025-02-04 01:11:28 字数 570 浏览 4 评论 0原文

该文件正在发送到nodejs服务器,但是上传。单声将出乎意料地结束表单错误。我该如何解决?

const upload = multer({ dest: "../../uploaded_images" });    
router.patch("/profile", upload.single("profileImage"), (req, res) => {   
    console.log(req.files) // This shows that there is a file named profileImage, I can see that when I remove the upload.single("profileImage")
    res.send("")
})

文件结构:

“在此处输入图像描述”

The file is being send to the nodejs server, but the upload.single gives an unexpected end of form error. How do i fix this?

const upload = multer({ dest: "../../uploaded_images" });    
router.patch("/profile", upload.single("profileImage"), (req, res) => {   
    console.log(req.files) // This shows that there is a file named profileImage, I can see that when I remove the upload.single("profileImage")
    res.send("")
})

the file structure:

enter image description here

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

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

发布评论

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

评论(1

各自安好 2025-02-11 01:11:28

这似乎是Multer本身的错误。我通过将Multer降至1.4.3而解决。

请参阅 https://github.com/expressjs/multer/multer/multer/issues/1144

It seems to be a bug in Multer itself. I solved by downgrading Multer to 1.4.3.

See https://github.com/expressjs/multer/issues/1144

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