【发布时间】:2014-06-13 03:13:44
【问题描述】:
我很想使用 DropZone 将文件上传到我的 nodejs 服务器。但是,当帖子到达我的 nodejs 服务器时,我不知道如何获取文件句柄。以下是我在 html 中实例化 DropZone 的方法:
<form action="/file-upload" class="dropzone" id="logoDropZone">
<input type="hidden" name="userName" value="user"/>
</form>
然后,在我的 nodejs 服务器中,我有以下代码:
app.post('/file-upload', function (request, response) {
console.log("Route: '/file-upload' ");
console.log("File upload request from user: " + request.body.userName);
// Get a file handle, read the file and then write it out to the file system.
...
});
我可以看到这段代码正在执行。我还可以通过请求对象访问输入字段中的值(请参阅隐藏的输入)。但是,如何访问文件本身以便将其写入服务器文件系统?
【问题讨论】:
-
把它放在你的
标签: javascript node.js file-upload dropzone.js