Martin
Martin

Reputation: 1134

Ext JS can't get file to upload

I am using Ext JS 3.4 and having an issue getting files to upload from a form The PHP script is failing to receive the file data (even trying just with a print_r($_FILES) which should show any file or error received).

this is my code

var editOrganisationForm = new Ext.FormPanel({
    url: 'appsrv/users_json.php',
    labelWidth: 75,
    border:false,
    width: 350,
    items: {
        xtype:'tabpanel',
        layoutOnTabChange: true,
        deferredRender:true, 
        border: false,
        activeTab: 0,
        defaults: {autoHeight:true, bodyStyle:'padding:10px; border: 0', bodyBorder: false}, 
        items:[{
            title:'Organisation Info',
            layout: 'form',
            fileUpload: true,
            defaults: {width: 230},
            defaultType: 'textfield',
            items: [
                {xtype: 'hidden', name: 'id'},
                {fieldLabel: 'Organisation', name: 'organisation', allowBlank:false},
                {
                    fieldLabel: 'Logo',
                    name: 'org_logo',
                    id: 'org_logo',
                    inputType: 'file',
                    allowBlank:true
                },
                {
                    fieldLabel: 'Theme',
                    name: 'org_theme',
                    id: 'org_theme',
                    store: [['val1', 'First Value'], ['val2', 'Second Value']],
                    xtype: 'combo',
                    allowBlank: false,
                    forceSelection: true,
                    valueField:'id',
                    displayField:'name'
                }
            ]
        }]
    }
});

and

var winOrg = new Ext.Window({
        title: 'Edit Organisation',
        layout:'fit',
        width:400,
        height:215,
        closeAction: 'hide',
        plain: false,
        modal: true,
        shadow: true,
        items: [editOrganisationForm],
        buttons: [{
            text:'Save',
            handler: function() {
                editOrganisationForm.getForm().submit({
                    method: 'POST',
                    waitTitle: 'Please Wait...',
                    waitMsg: 'Saving Changes',
                    url: 'appsrv/users_json.php',
                    params: {cmd: "addOrg"},
                    success: function() {
                        Ext.Msg.alert('Complete','Your changes have been saved');
                        tree.root.reload();
                        winOrg.hide();
                    },
                    failure: function(form, action) {                   
                        if (action.failureType == 'server') {
                            obj = Ext.util.JSON.decode(action.response.responseText);
                            Ext.Msg.alert('Oops!', obj.errors.reason);
                        } else if (action.failureType == 'client') {
                            Ext.Msg.alert('Sorry', 'Please ensure all required fields have been completed');
                        } else {
                            Ext.Msg.alert('Sorry','An error occurred');
                        }
                    }
                });
            },
            disabled: false
        }]
});

Upvotes: 0

Views: 1130

Answers (2)

Martin
Martin

Reputation: 1134

That's me solved it fileUpload: true was correct but I had it in the wrong object, it should have been in the form config object and not in the form>panel>items object

Upvotes: 2

Vikas Prabhu
Vikas Prabhu

Reputation: 54

include isUpload: true in the form config object

Upvotes: 1

Related Questions