Node.js 将图像文件数据从前端发送到后端
有没有办法将图像文件从前端发送到后端?我需要将表单中选择的图像上传到cloudinary云平台 使用Node.js 将图像文件数据从前端发送到后端,node.js,file,image-uploading,cloudinary,Node.js,File,Image Uploading,Cloudinary,有没有办法将图像文件从前端发送到后端?我需要将表单中选择的图像上传到cloudinary云平台 使用req.body访问文件输入没有帮助,并且会给我一个错误,说没有这样的文件或目录打开 如果我添加enctype=“multipart/form data”,然后在后端执行req.on('data',(data)=>{console.log(data.toString)},然后执行到cloudinary的上载,它会失败并给出以下错误:错误:路径必须是没有空字节的字符串 这是我的表格: <for
req.body
访问文件输入没有帮助,并且会给我一个错误,说没有这样的文件或目录打开
如果我添加enctype=“multipart/form data”
,然后在后端执行req.on('data',(data)=>{console.log(data.toString)}
,然后执行到cloudinary的上载,它会失败并给出以下错误:错误:路径必须是没有空字节的字符串
这是我的表格:
<form method="post" action="/submitArticle" enctype="multipart/form-data">
<div class="file">
<label class="file-label">
<input class="file-input" type="file" name="image">
<span class="file-cta">
<span class="file-icon">
<i class="fa fa-upload"></i>
</span>
<span class="file-label">
Choose a file…
</span>
</span>
</label>
</div>
<div class="field">
<label class="title is-4">Title</label>
<div class="control">
<input class="input" name="title" type="text" placeholder="Give your story a title...">
</div>
</div>
<div class="field">
<label class="title is-4">Story</label>
<div class="control">
<textarea class="textarea" name="story" rows="7" placeholder="Tell your story here..."></textarea>
</div>
</div>
<div class="field is-grouped is-grouped-right">
<p class="control">
<input class="button is-primary" type="submit">
</input>
</p>
</div>
</form>
选择一个文件…
标题
故事
是否有其他方法将图像数据从前端发送到后端?提前谢谢 您可以使用第三方库在前端上载图像并将其发送到后端。简单的是,< p>如果你想上传到CydiDyTy,也许你应该考虑使用.< /P> 该小部件支持将图像直接从浏览器上载到Cloudinary存储,而无需让服务器参与该过程