nodejs express 上传文件

来源:互联网 发布:linux vim 强制退出 编辑:程序博客网 时间:2024/06/02 15:32

1,express集成了formidable库

    使用app.use(express.bodyParser({uploadDir:TEST_TMP,keepExtensions:true});

    来更改上传目录,并保留原文件的后缀名

2,读取上传的该文件信息代码如下:

exports.upload = function(req,res,next){
 
       var filename = req.files.upload.path;   //文件存放绝对路径
       var title = req.files.upload.name;      //上传后解析过的文件名

       console.log(req);  //通过看req的内容就知道了
 };

原创粉丝点击