View Full Version : FileUpload from a Toolbar Button doesn't POST any data for me

29 Oct 2009, 4:48 PM
Hello, I'm trying to implement a file import button for an editor grid in a Tab, to import an excel spreadsheet for example. But I seem to be running into a few difficulties.

The main problem is that the POST data is empty according both to firebug and the import function that is associated with the url statement in the code below.

The current button setup is below, which is just one of a few toolbar buttons already in place on the grid, but the only form in the toolbar, the id used does not conflict with the editorgrid id.

I am running on version 3.0.0

fbutton = {
xtype : 'form',
id : 'spreadForm',
fileupload : true,
hideLabels : true,
baseCls : 'x-toolbar-cell',
items : [{
xtype : 'fileuploadfield',
fileupload : true,
buttonOnly: true,
buttonText : 'Import..',
buttonCfg : {
iconCls : 'import'
name : 'importfile',
id : 'importfile',
listeners: {
'fileselected': function(fb, v) {
if (Ext.getCmp('spreadForm').getForm().isValid()) {
fileupload : true,
url : '/process/spread/import/',
method : 'POST',
waitMsg : 'Validating Import...',
success : onSuccess,
failure : onFailure
} else {
alert("File upload form invalid");

Alerting on the "v" variable passed to the fileselected event does supply the correct filename selected by the Import (browse) button.

I have tried the following with varying results
1) Setting standardSubmit to true -> the post functions here but it posts to the wrong url (the main page url) as opposed to the required url.
2) Not encapsulating the fileuploadfield in a form. I could not work out how to submit this.
3) Putting the url,method,waitMsg etc in the main form definitions, and not in the submit handler, putting them in both, with no apparent change in operation.

If I could get some pointers here as to where I can look, or what I can do, it would be greatly appreciated.

29 Oct 2009, 7:33 PM
My apologies.

Please let me rephrase that line.

When the submit function is called, firebug registers a post to the correct URL, but the post section of the request packet to the web server is empty, so whilst it indicates a POST has been done, nothing has actually been sent

I have also tried adding a hidden parameter to the form items, and it is also not displayed in the post data section of the request to the server.

I have attached the firebug output image.

30 Oct 2009, 12:37 AM
what does

return in firebug?

1 Nov 2009, 3:39 PM
what does

Ext.getCmp('spreadForm').getForm().getValues() return in firebug?

Many thanks, a pointer to work from.

>>> Ext.getCmp('spreadForm').getForm().getValues()
Object =undefined

Interestingly, the following does respond with an object but the id is an ext generated one.


>>> Ext.getCmp('spreadForm').getForm()
Object xtype=form id=ext-gen40 fileupload=true

Would this have something to do with it?

1 Nov 2009, 6:58 PM
Many thanks to all that helped and looked at this.

I have located the problem. It was a silly typo, instead of "fileUpload" I had "fileupload", correcting this fixed my problem.