I\'m having trouble uploading a pdf, when I upload it (I\'m using ng-file-upload
) the file json that reachs express.js is:
{ fieldname: \'file\',
var express = require( 'express' ),
router = express.Router(),
util = require( 'util' ),
multer = require( 'multer' );
var storage = multer.diskStorage(
{
destination: './uploads/',
filename: function ( req, file, cb ) {
//req.body is empty...
//How could I get the new_file_name property sent from client here?
cb( null, file.originalname+ '-' + Date.now()+".pdf");
}
}
);
var upload = multer( { storage: storage } );
router.route( '/upload' )
.post( upload.single( 'file' ), post );
function post( request, response ) {
response.json( { message: 'Files Uploaded!' } );
}