I am working on the ability to upload files in extjs + php. I want to download a file or image from extjs and send it to the server side, which I am developing in PHP. In extjs, I have the view file code as -
Ext.define('Balaee.view.kp.dnycontent.Content',
{
extend:'Ext.panel.Panel',
requires:[
'Balaee.view.kp.dnycontent.ContentView'
],
id:'ContentId',
alias:'widget.Content',
title:'This day in a history',
items:[
{
xtype: 'fileuploadfield',
hideLabel: true,
emptyText: 'Select a file to upload...',
id: 'upfile',
width: 220
}],
buttons:[
{
text: 'Upload',
handler: function () {
var file = Ext.getCmp('upfile').getEl().down('input[type=file]').dom.files[0]; console.log(file);
var reader = new FileReader();
filecontent=reader.readAsBinaryString(file);
console.log(filecontent);
}
}
]
});
Therefore, when I try to load an animation file with the above code. The above line:
Ext.getCmp('upfile').getEl().down('input[type=file]').dom.files[0];stores file information as:
File {
webkitRelativePath: "",
lastModifiedDate: Tue Jul 14 2009 11:02:31 GMT+0530 (India Standard Time),
name: "Koala.jpg",
type: "image/jpeg",
size: 780831âĻ
}
i.e. The information associated with the file is obtained. But the actual contents of the file does not get. So what do I need to change to get the downloaded file?
source
share