1
下面的node.js服務器代碼允許客戶端將文件上載到臨時位置。使用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腳本的當前文件夾?
的[與node.js的上傳文件]可能的複製(http://stackoverflow.com/questions/23263307/upload-files-with-node-js) – Shanoor
process.cwd()會給你的節點腳本的當前工作目錄。結帳fs.copy –