PDA

View Full Version : ExtJS File upload



rmoritz
17 Mar 2009, 3:58 AM
Hello community,

i need some help with the extjs data connection.

i build my own form:


var content = "<form id='test'>";
content += "<fieldset><legend><label><strong>Data</strong></label></legend>";
content += "Name: <input type='text' id='name'/>";
content += "</fieldset>";
content += "<fieldset><legend><label><strong>File</strong></label></legend>";
content += "File: <input type='file' id='pdf'/>";
content += "</fieldset>";
content += "<br><button id='perform'>perform</button>";
content += "</form>";

Ext.get("content").dom.innerHTML = content;
Ext.get("perform").on('click', function(){
var conn3 = new Ext.data.Connection();
conn3.request({
url: 'index.php?ajax=1&method=save',
params: {"name": Ext.get("name").dom.value},
method: 'POST',
isUpload: true,
headers: {'Content-type':'multipart/form-data'},
success: function(responseObject3) {
var response3=responseObject3.responseText;
response3=eval(response3);
},
failure: function() {
Ext.Msg.alert('Status', 'Unable to connect.');
}
});
});


when i try to perform the request the $_FILES-var in the php-file is alway empty. what is wrong?

thank you.

best regards,
robert

Animal
17 Mar 2009, 4:02 AM
You can't upload through Ajax.

What's all this generated HTML mess?

Create an Ext.form.FormPanel using fileUpload: true