ExtJs4.2,文件上传,无法提交至指定URL。用浏览器调试JS,发现总报如下的错:
Uncaught NotFoundError: Failed to execute 'appendChild' on 'Node': The new child element is null.
我的JS代码如下:
Uncaught NotFoundError: Failed to execute 'appendChild' on 'Node': The new child element is null.
我的JS代码如下:
items : [ {
xtype : 'textfield',
inputType : 'file',
///id : ...
} ]
继续用浏览器调试跟踪:
//ext-all-dev.js:124759L
isFileUpload: function() {
return this.inputType === 'file'; //返回true
},
//ext-all-dev.js:121545L
// Special handling for file upload fields: since browser security measures prevent setting
// their values programatically, and prevent carrying their selected values over when cloning,
// we have to move the actual field instances out of their components and into the form.
len = uploadFields.length;
for (i = 0; i < len; ++i) {
el = uploadFields[i].extractFileInput(); //返回null
formEl.appendChild(el); //报错:Uncaught NotFoundError
uploadEls.push(el);
}
//ext-all-dev.js:123915L
extractFileInput: function() {
return null;
},
经查,发现filefield的extractFileInput返回的不是null,所以,试着将上述的代码修改为:
items : [ {
xtype : 'filefield',
///id : ...
} ]
问题解决!