expressjs中的绝对文件上传路径

时间:2013-11-06 05:32:16

标签: file-upload express relative-path absolute-path

我可以设置文件上传路径到/fileupload1文件夹,但是如何设置文件上传路径到/fileupload2文件夹?感谢

myapp
     /config
            config.js
            express.js
            /fileupload1
     /public
            /fileupload2
     server.js

server.js

var express = require('express'),
    fs = require('fs'),
var app = express(),
    app.use(express.static(__dirname + '/public'));
exports = module.exports = app;

express.js

var express = require('express'),
module.exports = function(app, config) {
    app.use(express.static(config.root + '/public'));
    app.use(express.bodyParser({ keepExtensions: true, uploadDir: __dirname + "/fileupload1" }))
};

1 个答案:

答案 0 :(得分:0)

试试这个:

express.bodyParser({
  keepExtensions: true,
  uploadDir     : __dirname + "/../public/fileupload2"
})