我从 AngularJS 发布到一个强大的表单,但该表单无法解析。我不使用 express.bodyParser(),我理解这通常是一个问题。
服务器端:
...
var form = new formidable.IncomingForm();
console.log(form); //this prints
//Get access to the other fields of the request.
form.parse(req, function (err, fields, files) {
console.log("parsing.."); //this does not print
console.log(fields);
console.log(files);`
...
客户端:
...
$http({
method: 'POST',
url: '/api/ad',
data: message, // your original form data,
transformRequest: formDataObject, // this sends your data to the formDataObject provider that we are defining below. `[see this](https://stackoverflow.com/questions/17629126/how-to-upload-a-file-using-angularjs-like-the-traditional-way)`
headers: {'Content-Type': undefined}
})
.success(function(data, status, headers, config){
deferred.resolve(data); `
...
使用 formData 对象发布表单 Angular 时,我必须将内容/类型设置为未定义,如此处的评论中所述。这可能是强大的问题吗?
我一直在用几个小时试图解决这个问题,但没有运气。我将非常感谢任何答案!