【发布时间】:2016-02-28 02:34:18
【问题描述】:
下面的 node.js 服务器代码允许客户端将文件上传到临时位置。
var restify = require('restify');
var server = restify.createServer();
server.use(restify.bodyParser());
server.post('/fileupload', function(req, res, next){
var path_temp = req.files.file.path;
console.log(path_temp);
res.end('upload');
next();
});
server.listen(8000);
上传的文件存储在文件夹位置path_temp。如何将此文件复制到正在运行的 node.js 脚本的当前文件夹?
【问题讨论】:
-
process.cwd() 将为您提供节点脚本的当前工作目录。结帐 fs.copy
标签: javascript node.js file-upload upload file-move