Results 1 to 2 of 2

Thread: Ext.form.field.FIle - How to get file

  1. #1
    Sencha User
    Join Date
    Jul 2015
    Posts
    5

    Default Ext.form.field.FIle - How to get file

    Hi,

    I am currently working in Architect 3 building a from that will upload two files and send them to a CFC to parse the data in the excel documents. I am currently using a submit button with a handler that uses the form.submit() function to call the cfc file but I never seem to get the file on the cold fusion side.

    Ext.define('admin.view.UploadWindow', {
    extend: 'Ext.window.Window',
    alias: 'widget.uploadwindow',


    requires: [
    'admin.view.UploadWindowViewModel',
    'admin.view.UploadWindowViewController',
    'Ext.form.Panel',
    'Ext.form.field.ComboBox',
    'Ext.form.field.File',
    'Ext.toolbar.Toolbar',
    'Ext.toolbar.Fill',
    'Ext.button.Button'
    ],


    controller: 'uploadwindow',
    viewModel: {
    type: 'uploadwindow'
    },
    autoShow: true,
    border: false,
    resizable: false,
    width: 500,
    layout: 'fit',
    title: 'Upload',


    items: [
    {
    xtype: 'form',
    frame: true,
    id: 'form',
    bodyPadding: 15,
    items: [
    {
    xtype: 'combobox',
    anchor: '100%',
    fieldLabel: 'Select Month',
    displayField: 'Month',
    store: 'MonthStore'
    },
    {
    xtype: 'filefield',
    anchor: '100%',
    id: 'LaborFile',
    fieldLabel: 'Labor',
    msgTarget: 'side',
    allowBlank: false,
    allowOnlyWhitespace: false
    },
    {
    xtype: 'filefield',
    anchor: '100%',
    fieldLabel: 'Expense'
    }
    ],
    dockedItems: [
    {
    xtype: 'toolbar',
    dock: 'bottom',
    items: [
    {
    xtype: 'tbfill'
    },
    {
    xtype: 'button',
    handler: function(button, e) {
    var form = this.up('form').getForm();
    if(form.isValid()){
    form.submit({
    url: 'resources/cfc/Upload.cfc?method=JSONRequest',
    waitMsg: 'Uploading your file...',
    headers: {'Content-Type':'multipart/form-data; charset=UTF-8'},
    success: function(fp, o) {
    Ext.Msg.alert('Success', 'Your file "' + o.result.file + '" has been uploaded.');
    }
    });
    }
    },
    icon: 'resources/images/accept.png',
    text: 'Submit',
    listeners: {
    click: 'submitButtonClick'
    }
    },
    {
    xtype: 'button',
    icon: 'resources/images/cancel.png',
    text: 'Cancel',
    listeners: {
    click: 'cancelButtonClick'
    }
    }
    ]
    }
    ]
    }
    ]


    });

    I have looked at many examples online but nothing seems to be working. Am I currently missing something in my setup or can someone tell me how I would get the file data from the form to pass to my CFC function using an AJAX call. I have tried using a click listener on the submit button with my own AJAX call but I cant find the file in any of the data.

    I also noticed and found in the API that some browsers (Chrome) dont store the full path to the file but will I still be able to retrieve the file?

  2. #2
    Sencha - Support Team bjdurham85's Avatar
    Join Date
    Mar 2014
    Posts
    962
    Answers
    55

    Default

    I haven't used CFC much but are you able to output the request? **In PHP, I could output $_FILES not sure if equivalent for your scenario.

    Bryan

Similar Threads

  1. how to validate file length in ext.form.field.File
    By jiangpin in forum Ext: Discussion
    Replies: 3
    Last Post: 16 May 2013, 10:04 PM
  2. Replies: 1
    Last Post: 9 Mar 2012, 11:02 AM
  3. Replies: 1
    Last Post: 17 Oct 2011, 11:04 PM
  4. Ext.form.field.File, specify acceptable file extensions
    By ucabazz in forum Ext: Discussion
    Replies: 0
    Last Post: 3 May 2011, 5:14 AM

Posting Permissions

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