Hybrid View

  1. #1
    Sencha Premium Member
    Join Date
    Feb 2013
    Posts
    50
    Answers
    1
    Vote Rating
    2
    vicvolk87 is on a distinguished road

      0  

    Default Answered: Submitting several filefields

    Answered: Submitting several filefields


    Hello, guys! Please help, if you know how. The problem is I have a form with three filefields. When the user presses the button, the form is submitted. But instead of submitting all files it sumbits only the last one. Previously I faced a similar problem, when I tried to submit combobox multiple values, and the trick was to name the field with extra brakets - [] in order to treat the field as an array. But in this case I have three unique fields and want to submit them all.

    Really need your help. Thank you, guys!

    PS It would be extremely great if you could share the simplest example with just two filefields.

  2. I see it sending 3 files:

    Code:
    new Ext.form.Panel({
        renderTo    : document.body,
        title       : 'Test',
        url         : 'data/form.php',
        defaultType : 'filefield',
        items       : [
            {
                fieldLabel : 'One',
                name       : 'one'
            },
            {
                fieldLabel : 'Two',
                name       : 'two'
            },
            {
                fieldLabel : 'Three',
                name       : 'three'
            },
            {
                xtype   : 'button',
                text    : 'Submit',
                handler : function (button) {
                    var form = button.up('form');
    
                    form.submit();
                }
            }
        ]
    });

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,207
    Answers
    3517
    Vote Rating
    856
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      1  

    Default


    I see it sending 3 files:

    Code:
    new Ext.form.Panel({
        renderTo    : document.body,
        title       : 'Test',
        url         : 'data/form.php',
        defaultType : 'filefield',
        items       : [
            {
                fieldLabel : 'One',
                name       : 'one'
            },
            {
                fieldLabel : 'Two',
                name       : 'two'
            },
            {
                fieldLabel : 'Three',
                name       : 'three'
            },
            {
                xtype   : 'button',
                text    : 'Submit',
                handler : function (button) {
                    var form = button.up('form');
    
                    form.submit();
                }
            }
        ]
    });
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha Premium Member
    Join Date
    Feb 2013
    Posts
    50
    Answers
    1
    Vote Rating
    2
    vicvolk87 is on a distinguished road

      0  

    Default


    Thank you Mitchel! May I ask you one extra question? You organized all filefields in one container. But in an arbirtary situation there may be different types of fields and it is not necessary that all filefields come one after another. In my test case I have three separate filefields, that is

    Code:
    ...
    xtype:'form',
    items:[
    {xtype:'filefield',
    name:'file1'
    },
    {xtype:'filefield',
    name:'file2'
    },
    ]
    And if I submit this form, at the server side I see, that $_FILES has two files as it is expected, but if I check files' temporary names and try to upload them, it comes out that all files except the last one are empty.
    What should I do with this form organization?
    Thank you for attention and your help!

  5. #4
    Sencha Premium Member
    Join Date
    Feb 2013
    Posts
    50
    Answers
    1
    Vote Rating
    2
    vicvolk87 is on a distinguished road

      0  

    Default


    I was wrong. Your example is working. So, there is something with my code. The fact is I do not use an instance of form.Panel. Instead I use xtype:'form' inside a window and that may cause some misbehaviour.

Thread Participants: 1