【发布时间】:2014-06-24 03:27:35
【问题描述】:
我是nodejs 的新手。我基本上使用express,我必须创建一个表单来上传照片。到目前为止,我已经创建了一个名为 upload.handlebars 的文件,我在其中编写了以下代码:
<form enctype="multipart/form-data" action="uploads" method="post">
<input type="file", id = "image", name="image", accept="image/*">
<input type='submit' id='tags' value='Upload'>
我有另一个名为 router.js 的文件,我在其中编写了 post 函数。 post函数中的一行是:
fs.readFile(req.files.image.path, function (err, data) {
但是,我收到如下错误:
TypeError: Cannot read property 'image' of undefined at Object.handle....
我应该如何在我的router.js 中指定图像文件的“名称”?
【问题讨论】:
-
中的逗号是什么?
标签: node.js