Results 1 to 5 of 5

Thread: File upload in IE has broken after upgrading from 4.1.1 to 4.2.1

    Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha User
    Join Date
    Feb 2013
    Posts
    13

    Default File upload in IE has broken after upgrading from 4.1.1 to 4.2.1

    In my application i use file upload via form.submit():

    form.submit({
    url: 'upload?mediumid=' + record.get('id'),
    success: function() { ... },
    failure: function() { ... }
    });

    In 4.1.1 it worked without any problem.
    However, after having upgraded to 4.2.1 it has ceased working correctly in IE. It still works in Google Chrome for example.

    In IE the file gets correctly uploaded, however, I always get the error:

    'success' is null or not an object

    It seems to be utter nonsense.
    If I leave out callbacks and just call submit to upload the file, I still get the error.

    This has nothing to do with the response from the server. I get this error immediately upon starting an upload even when the file is big and takes order of seconds to upload and process.

  2. #2
    Sencha User slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,165

    Default

    The following test case seemed to work for me ok (I'm pointing to a file that didn't exist so got the normal sort of 404 error, but not what you're seeing) when testing with 4.2.1 in IE9. Does this test case represent your use case? If not, can you post your own standalone test case that demonstrates the issue (or modify the one below)?

    Code:
    Ext.create('Ext.form.Panel', {
        title: 'Upload a Photo',
        width: 400,
        bodyPadding: 10,
        frame: true,
        renderTo: Ext.getBody(),
        items: [{
            xtype: 'filefield',
            name: 'photo',
            fieldLabel: 'Photo',
            labelWidth: 50,
            msgTarget: 'side',
            allowBlank: false,
            anchor: '100%',
            buttonText: 'Select Photo...'
        }],
    
    
        buttons: [{
            text: 'Upload',
            handler: function() {
                var form = this.up('form').getForm();
                if(form.isValid()){
                    form.submit({
                        url: 'photo-upload.php',
                        waitMsg: 'Uploading your photo...',
                        success: function(fp, o) {
                            Ext.Msg.alert('Success', 'Your photo "' + o.result.file + '" has been uploaded.');
                        }
                    });
                }
            }
        }]
    });

  3. #3
    Sencha User
    Join Date
    Feb 2013
    Posts
    13

    Default

    Hi,

    Sorry for the delay.
    I have just tried your example.
    It works for me, if photo-upload.php does not exist. In such a case the 'failure' callback is called.
    However, if I create photo-upload.php and put the following into it:

    <?php
    header('Content-Type: text/plain');
    ?>
    {"data": "OK", "success": true}

    then I see the same erroneous behavior.

    It blows in the file extjs/src/form/action/Submit.js on line 270 in the function:

    onSuccess: function(response) {
    var form = this.form,
    success = true,
    result = this.processResponse(response);
    if (result !== true && !result.success) {
    if (result.errors) {
    form.markInvalid(result.errors);
    }
    this.failureType = Ext.form.action.Action.SERVER_INVALID;
    success = false;
    }
    form.afterAction(this, success);
    },


    For some reason this.processResponse(response) returns undefined, so "result. success" is doomed to blow up. I am unable to locate the corresponding processResponse function to debug further.

  4. #4
    Sencha User
    Join Date
    Feb 2013
    Posts
    13

    Default Solved

    Finally I traced the problem to extjs/src/data/Connection.js, where I found out that I had used an incorrect Content-Type. It should be 'text/html' instead of 'text/plain'.

    Only IE + extjs 4.2.1 exhibited the problem. Any combination of any other browser or extjs 4.1.1. worked fine.

  5. #5
    Sencha User slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,165

    Default

    Thanks for posting back with the solution!

Posting Permissions

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