图像未在节点js中上传

时间:2015-11-25 06:50:39

标签: javascript node.js

我正在尝试在节点js中上传图片。

我的用户路径代码是

var multer = require('multer');
var app    =   express();
var upload      =   multer({ dest: './uploads/'});
var dateFormat = require( 'dateformat' );

app.use( multer({ dest: './uploads/',

    rename: function (fieldname, filename) {
        return filename+Date.now();
    },
    onFileUploadStart: function (file) {
        console.log(file.originalname + ' is starting ...');
    },
    onFileUploadComplete: function (file) {

        console.log(file.fieldname + ' uploaded to  ' + file.path)
    }
}));
router.post( '/upload-picture', function( req, res, next ) {            

    upload(req,res,function(err) {
        if(err) {
            return res.end("Error uploading file.");
        }
        res.end("File is uploaded");
    });
});

上传文件夹只是回到routs文件夹的一步,与routs文件夹一起。

文件已上传消息,但图片未上传到文件夹中。我在哪里做错了?

0 个答案:

没有答案