PDA

View Full Version : File Upload



giovannotti
3 Jun 2009, 1:15 PM
hi all, I have a problem with a file upload.
upload this file invokes the corresponding action, for processing and then populate a grid with the information that was read.

the problem is that when the action will open a window indicating that you download will download, for example, readFileAction.action and therefore does not fill the grid.

I am wrong in how I'm doing?

var fileUploadPanel = new Ext.FormPanel({
renderTo: 'fi-form',
fileUpload: true,
width: 200,
frame: false,
border : 0,
labelWidth: 142,
margins: '0 0 0 0',
cmargins: '0 0 0 0',
bodyStyle:'padding:5px 15px 5px 10px',
tooltip : 'Load items from a text file',
items: [
{
xtype: 'fileuploadfield',
id: 'form-file',
name: 'filePath',
buttonOnly : true,
fieldLabel: 'Load file ...',
//emptyText: 'Seleccione',
//width: 5,
buttonCfg: {
text: '',
iconCls: 'x-btn-addGrid-blue'
},
listeners: {
'fileselected' : function(fb, v) {
var preg = "Are you sure?";

Ext.MessageBox.confirm('Confirm', preg, function(btn) {
var resp = "" + btn;
if ( resp == "yes") {
var url = "";
url = _ACTION_UPLOAD_FILE;

if ( fileUploadPanel.getForm().isValid() ) {
fileUploadPanel.getForm().submit({
url: url,
waitMsg: 'Wait...',
success: function(fp, o){
alert('File "'+o.result.file+'" on server');
},
failure: function (){
alert("Fail");
}
});
}
}
});
}
}
}
]
});

aconran
4 Jun 2009, 8:11 AM
the problem is that when the action will open a window indicating that you download will download, for example, readFileAction.action and therefore does not fill the grid.


Could you explain the issue that you are encountering in further detail? I don't understand what's happening.

giovannotti
5 Jun 2009, 12:14 PM
Could you explain the issue that you are encountering in further detail? I don't understand what's happening.

Sorry if I did not explain properly
The page contains a button to upload file
This opens a windows explorer to select the file
After this, the file is processed and the result is stored in a To(bean), which must be used to fill a editor grid, but it opens a window for download a file named loadGridAction.action

Animal
5 Jun 2009, 12:18 PM
The response is wrong then. The server must send back a JSON response as described in the docs.

http://extjs.com/deploy/ext-3.0-rc2/docs/?class=Ext.form.Action.Submit

Animal
5 Jun 2009, 12:19 PM
See notes about file upload here: http://extjs.com/deploy/ext-3.0-rc2/docs/?class=Ext.form.BasicForm