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\',
In Angular you need to move new_file_name to be above file in data as follows:
Upload
.upload( {
url: '/upload',
data: {
new_file_name: vm.new_name, //this is the filename I want
file: vm.pdf
}
} )
Basically browser needs to send that data before the file ... Better explanation can be found here: https://github.com/expressjs/multer/issues/134