Closed
Description
I'm struggling to get a filename passed from server/app.js to a controller in client/app/
I am using Multer to deal with the file upload which is working fine but i need to pass the filename back to the client to display it in the next view.
Here is the code i have:
server/app.js
app.use(multer({ dest: 'client/assets/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)
done=true;
}
}));
app.post('/api/photo',function(req,res){
if(done==true){
photoName = req.files.userPhoto.name;
res.json(photoName);
}
});
It's showing the new filename but i need it to be in a usable form and as i'm doing all this server side i have nothing in my controller to handle the incoming response.
Any help would be greatly appreciated.
Metadata
Metadata
Assignees
Labels
No labels