Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: fileUpload: Unable to passing additional parameter on a submit

  1. #1

    Default fileUpload: Unable to passing additional parameter on a submit

    Hello,
    Parameters are not being passed in the request when doing a form submit for a form that has a fileUpload: true .

    In firebug I see the values being set but when I get to the java action and inspect the request parameters there are no additional values other than the uploaded file.
    I've also tried hidden fields in the form but that didn't work.
    I also tried to set the values on the form (see bellow..)

    Using ext 2.0.2

    Any ideas??
    Thank You.
    -Boynton.

    js follows..

    Ext.ux.FileUploadDialog = function()
    {

    var fp = new Ext.FormPanel({
    fileUpload: true,
    url: 'uploadConfigurationFile.htm',
    fileType: '',
    deviceName: '',
    width: 500,
    frame: true,
    title: 'File Upload Form',
    autoHeight: true,
    bodyStyle: 'padding: 10px 10px 0 10px;',
    labelWidth: 50,
    defaults: {
    anchor: '95%',
    allowBlank: false,
    msgTarget: 'side'
    },
    items: [{xtype:"textfield",inputType:'file',fieldLabel:"File",name:"file",allowBlank:false}],
    buttons: [
    {
    text: 'Upload',
    handler: function(){
    if(fp.getForm().isValid()){
    fp.getForm().enctype='multipart/form-data';
    fp.getForm().encoding='multipart/form-data';
    fp.getForm().id=fp.deviceName;
    fp.getForm().type=fp.fileType;

    fp.getForm().submit({
    params:{id: fp.deviceName, type: fp.fileType},
    success: function(f,a){
    Ext.Msg.alert('worked');
    },
    failure: function(f,a){
    Ext.Msg.alert('not worked');
    }
    });
    }
    }
    }
    ,
    ]
    });

    return Ext.apply(new Ext.Window({
    width:500,
    height:300,
    closeAction:'hide',
    plain: true,
    modal: true,
    items: fp,
    id:'fileUploadWindow'

    }),{
    showDialog: function(fileType, deviceName) {
    fp.fileType = fileType;
    fp.deviceName = deviceName;

    this.show();
    }
    });


    }();

  2. #2
    Ext User
    Join Date
    Aug 2009
    Location
    California
    Posts
    1

    Default

    Hi,

    I'm seeing the same EXACT error. Does anyone know what the problem might be?
    I am a tech and web enthusiast, currently working on new for Halo Reach.

  3. #3
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258

    Default

    getForm() returns a BasicForm object, not the dom form.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  4. #4

    Default What worked for me..

    I'm using http://commons.apache.org/fileupload/using.html
    see code abstract below..

    // Create a factory for disk-based file items
    DiskFileItemFactory factory = new DiskFileItemFactory();
    //factory.setFileCleaningTracker(fileCleaningTracker);

    // Create a new file upload handler
    ServletFileUpload upload = new ServletFileUpload(factory);

    // Parse the request
    List <FileItem> items = upload.parseRequest(request);
    Iterator <FileItem>iter = items.iterator();

    String type = "";
    String fileName = "";
    File file = null;

    while (iter.hasNext()){
    FileItem item = (FileItem) iter.next();

    if (item.isFormField() && item.getFieldName().equalsIgnoreCase("type")) {
    type =item.getString();
    }

    if(!item.isFormField() && item.getFieldName().equalsIgnoreCase("file")) {
    //removes path information.
    fileName = FilenameUtils.getName(item.getName());
    file = new File(fileName);
    item.write(file);

    ....
    Thanks.

  5. #5
    Sencha User
    Join Date
    Dec 2009
    Posts
    425

    Question upload file with additional field

    Hi,
    I have a form with fileUpload: true.
    The file upload works fine but I want to pass a textfield's value along with the file to my server side.
    How can I do this?
    I am using Ext 3.1.1

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

    Default

    It's not in the form that you are submitnig?

    Then add its value to the params option.

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

    Default

    It's not in the form that you are submitting?

    Then add its value to the params option.

  8. #8
    Sencha User
    Join Date
    Dec 2009
    Posts
    425

    Default

    Animal,
    My form contains a FileUploadField and a TextField.
    The form has fileUpload: true. With this config, I can access the file on my server side but not the text field.
    If I remove the 'fileUpload: true' option, then I can access the text field.
    How can I get both?

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

    Default

    They are both submitted. This is a question about your server side, not ExtJS.

  10. #10
    Sencha User
    Join Date
    Dec 2009
    Posts
    425

    Thumbs up

    Thank you, Animal.

    Indeed the form gets submitted along with all its items but the way to extract them on the server is different when fileUpload is turned on.
    In ASP, the textfield value can be accessed as...

    Code:
     
    HttpContext postedContext = HttpContext.Current;
    string id=postedContext.Request.Form["id"];

    and the uploaded file as
    Code:
     
    postedContext.Request.Files[0];

Page 1 of 2 12 LastLast

Posting Permissions

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