PDA

View Full Version : File Upload problem



salgaf
6 Oct 2010, 5:39 AM
Hi,

I'm trying to implement file upload in my web application.
I have followed api documentation and used FileUploadField extension.
Here is my code:

this.fieldUploadMan.add(new Ext.ux.form.FileUploadField({
emptyText: 'Select .tar file',
fieldLabel: 'File name',
width:300
}));

this.fieldUploadMan.add({
xtype: 'button',
text: 'Upload',
type: 'submit',
width: 150,
handler:function(){
this.panWebLct.getForm().submit({
url:'/goform/upldForm?applymode=on&savemode=on',
waitMsg: 'Uploading...',
success: function(form, action) {
Ext.Msg.alert('Success', action.result.msg);
},
failure: function(form, action){
Ext.Msg.alert('failure', action.failureType+ ' , '+ action.response+' , '+ action.result);
}
});
}.createDelegate(this)
});
This is only a subset of my code:
this=reference to Ext.Panel main container
this.fieldUploadMan=reference to Ext.form.FieldSet
this.panWebLct=reference to Ext.form.FormPanel

The problem is that the server response is in HTM format as follows:

<html>
<br><h1> MACHINE 192.168.74.30 NOT LOGGED </h1> <br>WEBS: upload DISCARD file "Webs_17_N96103_1.2.0b7.tar" ( 1874 bytes ) <br>WEBS: accepted file: "webs_18_XXX.tar"
</html>When Ext try to decode the response fall in syntax error.
There is any mode to avoid decoding the response because I don't need it.
What I need is to get the HTTP response code, for example 200,500,506
I can't modify the server response because is third part software.

Sorry for my school Eglish

Thank in advance

Condor
6 Oct 2010, 5:47 AM
You could define a very simple error reader, e.g.

errorReader: {
read: function(response){
return {success: true}; // or false based on the response
}
}

Animal
6 Oct 2010, 6:15 AM
The responseXML of the pseudo XHR passed to the reader should contain the HTML document.

The reader should be able to make sense of it.