javascript - HTTP 文件上传无法解析表单数据?
问题描述
我正在尝试pdf
使用html
表单将密码上传到我的cloud function
,但是在从请求正文中解析两者时返回未识别的错误。
这是 HTML:
<!DOCTYPE html>
<html>
<body>
<!-- curretly using emulator but the error is same if deployed-->
<form action="http://localhost:5000/ecutter-web/us-central1/test" method="post" enctype="multipart/form-data">
<input type="file" name="sfile" accept=".pdf">
<input type="text" name="spass">
<input type="submit">
</form>
</body>
</html>
如果我将它与 body `res.send(req.body) 一起发送回来,这就是 res 的外观:
-----------------------------1282136010350931161350789983 Content-Disposition: form-data; name="sfile"; filename="Aad.pdf" Content-Type: application/pdf %PDF-1.4 ..(returned as text here).. -----------------------------1282136010350931161350789983 Content-Disposition: form-data; name="spass" PDF12345 -----------------------------1282136010350931161350789983--
但是当我尝试使用解析它们中的一个req.body.sfile
或req.body.spass
它返回未定义时
为什么 ?
解决方案
推荐阅读
- ascii - ASCII码挑战
- python - 遍历一个将 range 作为元素的 lisit 并扩展它
- python-3.x - 嵌套字典理解提取一个键值对
- javascript - await 不等待承诺在节点 js 中返回
- python - 在 Flask MySQL 和 SqlAlchemy 命令 db.create_all() 中给出错误
- c++ - ADAPTIVE Communication Environment (ACE) C++ 库是否支持 iOS 和 Android?
- android - Xamarin Forms 上传图片 Laravel POST 请求失败
- javascript - 将开玩笑的数据传递给已安装的组件
- mysql - 我正在尝试连接 python 和 mysql,但遇到以下错误:
- python - 规范化或缩放熊猫多索引上的列