场景:我的 html 页面采用 json 文件作为输入并将其发送到 Nodejs 驱动的服务器组件。可以说,myPage.html
在此环境中是一个独立文件。
要求:我想捕获 htmlpage 请求,并将 json
嵌入到 httprequest 正文中。我不知道如何从html页面调用nodejs应用程序。
提前致谢
最佳答案
要发送文件(嵌入多部分请求正文中),您只需要一个常规的 HTML 表单。
<form action="http://example.com/nodejs/endpoint"
method="post"
enctype="multipart/form-data">
<label>
Select JSON file
<input type="file" name="json">
</label>
<input type="submit">
</form>
关于javascript - 从 html 访问 Nodejs 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34530224/