PDA

View Full Version : file upload with directSubmit



cornfelt
23 Sep 2009, 5:20 AM
Hi,

I have some trouble with the file upload by using directSubmit.
on server-side i use the implentation of tommy maintz.
the file is uploaded and i can do something with its content.

But Ext does not read out the response (the textarea) and so the submit handler
does not execute the success or failure functionality.

If I insert a waitmsg in the config. so the wait-widget is allways visible and
does not disappear.

my js-code:


var import = new Ext.Window({
id: 'import_win',
border: false,
constrain: true,
items: [{
xtype: 'form',
id: 'import_form',
anchor: '100% 100%',
bodyStyle: 'padding:5px',
api: {
submit : Ext.app.API_Con.importCon
},
method: 'POST',
labelAlign: 'top',
frame: false,
fileUpload: true,
items: [{
xtype: 'textfield',
fieldLabel: 'Bitte wählen ...',
inputType: 'file',
allowBlank: false
}]
}],
fbar: new Ext.Toolbar({
height: 22,
items: [{
xtype: 'tbbutton',
text: 'Import starten',
type: 'submit',
hideLabel: true,
handler: function() {
var import_form = Ext.getCmp('import_form').getForm();

import_form.submit({
clientValidation: true,
success : function(form, action) {
Ext.Msg.show({
title: 'Erfolg',
buttons: {
yes: 'OK'
}
});
},
failure : function(form, action) {
Ext.Msg.show({
title: 'Fehler',
msg: response.errors[0],
buttons: {
yes: 'OK'
}
});
return false;
}
});
}
}]
})
}).show();
firebugs console shows no request, but if i look at the network-tab, there I can
see the request and its response.

header:


Antwort-Header
Date Wed, 23 Sep 2009 12:45:08 GMT
Server Apache/2.2.8 (Linux/SUSE)
X-Powered-By PHP/5.2.9
Expires Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma no-cache
Content-Encoding gzip
Vary Accept-Encoding
Content-Length 159
Keep-Alive timeout=15, max=100
Connection Keep-Alive
Content-Type text/javascript
Anfrage-Header
Host cc4.rhea.test
User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 (.NET CLR 3.5.30729)
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 300
Connection keep-alive
Referer https://test/test/index.php
Cookie ...
POST:


Content-Type: multipart/form-data; boundary=---------------------------312402781329174
Content-Length: 2589
-----------------------------312402781329174
Content-Disposition: form-data; name="coma_upload_csv_file"; filename="Outlook02.csv"
Content-Type: application/octet-stream
...
some cvs-content
...
-----------------------------312402781329174
Content-Disposition: form-data; name="extTID"
7
-----------------------------312402781329174
Content-Disposition: form-data; name="extAction"
API_Con
-----------------------------312402781329174
Content-Disposition: form-data; name="extMethod"
importCon
-----------------------------312402781329174
Content-Disposition: form-data; name="extType"
rpc
-----------------------------312402781329174
Content-Disposition: form-data; name="extUpload"
true
-----------------------------312402781329174--
Antwort:


<html><body><textarea>{"type":"rpc","tid":"7","action":"API_Con","method":"importCon","result":{"success":true,"data":[1,0]}}</textarea></body></html>


what is wrong or there can I look for?

thanks,

cornfelt

mrsunshine
26 Sep 2009, 2:48 PM
header:


Antwort-Header
Date Wed, 23 Sep 2009 12:45:08 GMT
Server Apache/2.2.8 (Linux/SUSE)
X-Powered-By PHP/5.2.9
Expires Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma no-cache
Content-Encoding gzip
Vary Accept-Encoding
Content-Length 159
Keep-Alive timeout=15, max=100
Connection Keep-Alive
Content-Type text/javascript
Anfrage-Header
Host cc4.rhea.test
User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 (.NET CLR 3.5.30729)
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 300
Connection keep-alive
Referer https://test/test/index.php
Cookie ...


you have to set your response header to text/html and not to [COLOR=Red]text/javascript [COLOR=Black].

see more informations in doc (http://extjs.net/deploy/dev/docs/) Ext.form.BasicForm

mrsunshine
26 Sep 2009, 2:48 PM
you have to set your response header to text/html and not to text/javascript.

see more informations in doc (http://extjs.net/forum/../deploy/dev/docs/) Ext.form.BasicForm

Voronchuk
20 Jan 2010, 9:56 AM
This helped me too. Thanks.