nodejs formidable

node-formidable详解
博客园

express之前的版本包含formidable,之后的不包含。
下面介绍不包含的使用方法:

html

server:

path是物理地址,不是相对项目根目录的相对地址
files.key: key是html中的name

router.post('/file-upload', function(req, res, next){

    var form = new formidable.IncomingForm();
    form.uploadDir = "../test/public/images";
    form.parse(req, function(err, fields, files) {
    //重命名
        fs.renameSync(files.thumbnail.path, "../test/public/images/"+files.thumbnail.name);
    });
});

你可能感兴趣的:(nodejs formidable)