PDA

View Full Version : File Upload: Guaranteed to Work for you



dubiousdavid
8 Aug 2007, 11:43 AM
Edit Ext.form.Form, and add the following code:



if(this.fileUpload) {
o.enctype = 'multipart/form-data';
}


End result:



render : function(ct){
ct = Ext.get(ct);
var o = this.autoCreate || {
tag: 'form',
method : this.method || 'POST',
id : this.id || Ext.id()
};
if(this.fileUpload) {
o.enctype = 'multipart/form-data';
}
...

gurusingh
19 Aug 2007, 4:38 AM
can you plz post some code sample

Thanks in advance
Guru singh

mystix
19 Aug 2007, 10:43 PM
@gurusingh, what he means is, stuff this into your overrides file


Ext.override(Ext.form.Form, {
render : function(ct){
ct = Ext.get(ct);
var o = this.autoCreate || {
tag: 'form',
method : this.method || 'POST',
id : this.id || Ext.id()
};
if(this.fileUpload) {
o.enctype = 'multipart/form-data';
}
this.initEl(ct.createChild(o));

this.root.render(this.el);

this.items.each(function(f){
f.render('x-form-el-'+f.id);
});

if(this.buttons.length > 0){
// tables are required to maintain order and for correct IE layout
var tb = this.el.createChild({cls:'x-form-btns-ct', cn: {
cls:"x-form-btns x-form-btns-"+this.buttonAlign,
html:'<table cellspacing="0"><tbody><tr></tr></tbody></table><div class="x-clear"></div>'
}}, null, true);
var tr = tb.getElementsByTagName('tr')[0];
for(var i = 0, len = this.buttons.length; i < len; i++) {
var b = this.buttons[i];
var td = document.createElement('td');
td.className = 'x-form-btn-td';
b.render(tr.appendChild(td));
}
}
if(this.monitorValid){ // initialize after render
this.startMonitoring();
}
return this;
}
});