带数组的多部分/表单数据---------- /// ---------------------
我无法获得值“ fields.c”。
*---------------html form
<form action="/companyInfo" method="post" enctype="multipart/form-data">
<input type="text" name='txtCompanyPhone' value='0909 234 456' />
<input type="text" name='txtCompanyName[vi]' value='Namevi' />
<input type="text" name='txtCompanyName[en]' value='Nameen' />
<input type="text" name='txtCompanyName[ja]' value='Nameja' />
</form>
*---------------controller "companyInfo"
var form = new multiparty.Form();
form.parse(req, function(err, fields, files) {
console.log(fields);
//result
// txtCompanyPhone: ['0909 234 456'],
// ,'txtCompanyName[vi]': ['Namevi'],
// ,'txtCompanyName[en]': ['Nameen'],
// ,'txtCompanyName[ja]': ['Nameja'],
console.log(fields.txtCompanyPhone);
result------ ['0909 234 456']
console.log(fields.txtCompanyName[vi]);
//result ----- error
var c = 'txtCompanyName[vi]';
console.log(fields.c);
//result ------undefined
//----------Help me show results-----------------
}
如何以这种形式获取值“ fields.c”或“ fields.txtCompanyName [vi]”?
最佳答案
尝试fields['txtCompanyName']['vi']