PDA

View Full Version : Error Form Upload



Stephan123
6 Aug 2009, 12:11 AM
Hello !

I have a simple form.
--------------------


var fenster = new Ext.Window({
title: 'Upload',
width: 500,
autoHeight: 400,
frame: true,
renderTo: document.body,
id: 'fenster',
items: [{
xtype: 'form',
id: 'upload',
fileUpload: true,
frame: true,
items: [{
xtype: 'textfield',
inputType: 'file',
fieldLabel: 'CSV - Datei',
name: 'csvdatei',
id: 'csvdatei'
}],
buttons: [{
text: 'Upload',
handler: function(){

Ext.getCmp('upload').getForm().submit({
url: 'import/import.php',
params: {
aktion: 'ladeCsvDatei'
},
success: function(){
Ext.Msg.alert('Treffer');
}
});
}
},{
text: 'Abbrechen',
handler: function(){
Ext.getCmp('upload').getForm().reset();
}
}]
}]
});

fenster.show();

--------------------------------------

When i start the upload i becam an messag error
by the firebug.

'unexpected end of XML source'

Some idea ?

Greetings Stephan

Condor
6 Aug 2009, 12:23 AM
The server response for a file upload is different from a normal submit response.

Read this (http://extjs.com/deploy/dev/docs/?class=Ext.form.BasicForm).

Stephan123
6 Aug 2009, 1:14 AM
Hi !

I'm a little bit confused.

The header in the Html - file is

---------
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

-------------

The response from the server is made by

-------------------
header('Content-Type: text/html');
echo '{success:true, file:'.json_encode($_FILES['myFile']['name']).'}';

-----------------

Please help !

Greetings Stephan

Condor
6 Aug 2009, 1:19 AM
You missed the section about it needing to be HTML encoded:

Characters which are significant to an HTML parser must be sent as HTML entities, so encode "<" as "&lt;", "&" as "&amp;" etc.
Your code will fail if the filename contains a < or & character.

Stephan123
6 Aug 2009, 1:29 AM
Hello !

But when i write

---------
echo "eeee";
-----------

There is also an error. But why ?
Ther is not a special char ?


Greeting

Stephan

Condor
6 Aug 2009, 1:33 AM
Yes, but after it is HTML decoded it still needs to be valid JSON for the form to process.

ps. Did you check with the Firebug Net tab (or Fiddler2 on IE) what exactly is returned by your server?

Stephan123
6 Aug 2009, 1:47 AM
Hello !

I see in the firebug the error

-----------
missing ) in parenthetical
chrome://firebug/content/blank.gif{success: true})
----------------

I need the O.K. from the server when the file upload is finished.
On the server file i have this little skript.

-----------------
header('Content-Type: text/html');

$wert = "{success: true}";
$wert = htmlspecialchars($wert);
echo json_encode($wert);

-----------------

It doesn't work :((

Stephan

Animal
6 Aug 2009, 2:06 AM
json_encode a string? What does that do?

As Condor keeps saying you have to actrually debug at the client end.

See what the browser is actually recieving usnig Firebug or Fiddler.