我对MEAN非常陌生,并尝试使用图像保存表单字段。当我管理req.body时,我得到了一个类似{}的空白数组。 请有人帮我。
角度服务文件
createMovie(data, image){
const formData = new FormData();
formData.append('movie-name', data.movie_name);
formData.append('casting_name', data.casting_name);
formData.append('director_name', data.director_name);
formData.append('movie_description', data.movie_description);
formData.append('producer', data.producer);
formData.append('ticket_price', data.ticket_price);
formData.append('image', image, data.movie_name);
this.http.post(`${this.uri}/create-movie`,formData).subscribe(response => {
console.log(response);
})
}
backend code
exports.createMovie = (req, res, next) => {
console.log(req.body);
}