Results 1 to 8 of 8

Thread: Error Form Upload

  1. #1
    Sencha User
    Join Date
    Feb 2009
    Posts
    264

    Default Error Form Upload

    Hello !

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

    Code:
    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
    Last edited by Condor; 6 Aug 2009 at 12:22 AM. Reason: Please post using [CODE] tags!

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    The server response for a file upload is different from a normal submit response.

    Read this.

  3. #3
    Sencha User
    Join Date
    Feb 2009
    Posts
    264

    Default Server response

    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

  4. #4
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    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.

  5. #5
    Sencha User
    Join Date
    Feb 2009
    Posts
    264

    Default specialchars

    Hello !

    But when i write

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

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


    Greeting

    Stephan

  6. #6
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    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?

  7. #7
    Sencha User
    Join Date
    Feb 2009
    Posts
    264

    Default Server response

    Hello !

    I see in the firebug the error

    -----------
    missing ) in parenthetical
    [IMG]chrome://firebug/content/blank.gif[/IMG]{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

  8. #8
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •