3

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 を投稿する場合、ここのコメントに記載されているように、コンテンツ/タイプを未定義に設定する必要があります。それは手ごわいにとって問題になるでしょうか?

私は何時間もかけてこれを理解しようとしてきましたが、運が悪かったです。どんな答えでもとても感謝しています!

4

1 に答える 1