PDA

View Full Version : how to get file uploaded from editor grid as a file object?



shruthi123
10 Mar 2015, 1:06 PM
Hi

I have created a grid having editor plugin, I have a column in the grid for file upload, I am using fileuploadfield for this purpose. This allows me to select a file.


//Here are the various components associatedwith the grid- file upload

//editor file field

var sFile = {
fileUpload:true,
xtype:'fileuploadfield',
name:'sFile'
};



//Column Model of the grid

var cm = new Ext.grid.ColumnModel({

columns: [ new Ext.grid.RowNumberer(),{
id:'sFile',
header: 'File',
dataIndex: 'sFile',
width: 200,
editor: sFile
}]
});




// create the editor grid

this.cgrid= new Ext.grid.GridPanel({
store: that.store,
cm: cm,
editable: true,
height: 200,
plugins: [editor],
clicksToEdit: 1,
enableColumnMove:false,

});





However when I try to access the file object,it is a String containing the path of the file, something like(C:\fakepath\.eprod)

How can I get a file object?? Should I provide a type in the jsonStore?
// This is how I am accessing the items inthe grid


var itemsInStore = that.cgrid.store.data.items;
form.submit({
url: '/Test/App/addFile.do',
params: {
sFile:itemData.sFile,
},
success: function(form, action) {
Ext.Msg.alert('Success');
},
failure: function(form, action) { ;
Ext.Msg.alert('Failed');
}
});


var itemData = itemsInStore[i].data;
//This is the value in the itemData variable

Object { sFile:"C:\fakepath\.eprod"}

I am stuck with this issue.Any suggestions would help


Thanks in advance

Gary Schlosberg
16 Mar 2015, 11:30 AM
I'm not sure if a fileupload field can be an editor in a grid because it utilizes a hidden iframe. You can find more information in the File Uploads section of this doc page:
http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.form.BasicForm

shruthi123
23 Mar 2015, 1:05 AM
Okay, Can I get the full upload path of the file..? That is like, C:\Desktop\Folder\FileToBeUploaded.xls instead of C:\fakepath\FileToBeUploaded.xls..?

Gary Schlosberg
23 Mar 2015, 3:52 PM
I don't think browsers will give you the full path, as it would be a security problem.

shruthi123
23 Mar 2015, 10:30 PM
@Gary

Thanks..
Any Suggestions on how I will be able to proceed?
Or any alternate way of achieving a file upload through grid..?

harrypottar
7 Dec 2015, 9:47 AM
This is an old thread but did you ever get it to work or find a workaround