Reputation: 2480
I want to get filesize when change function run. I try more but anything didn't work. How can i do that thanks
{
xtype: 'filefield',
name: 'upfile[]',
buttonConfig: {
text: 'add'
},
listeners: {
'change': function(f, value){
alert(f.size); // not filesize
}
}
}
Upvotes: 0
Views: 4393
Reputation: 21
listeners:{
change:function(inputFile, value){
console.log(inputFile.fileInputEl.dom.files[0].size)
}
}
Upvotes: 1
Reputation: 48236
the only universal solution is to upload the file to the server and get the file size back
for modern browsers (IE10 and all the others), you can use the HTML5 FileReader API
for IE 9 or less you can use Hariharan's solution
Upvotes: 1
Reputation: 3263
it is possible with ActiveX Objects
.
function getSize()
{
var myFSO = new ActiveXObject("Scripting.FileSystemObject");
var filepath = document.upload.file.value;
var thefile = myFSO.getFile(filepath);
var size = thefile.size;
alert(size + " bytes");
}
Please refer below link
http://www.sencha.com/forum/showthread.php?158445-How-can-i-get-the-size-of-the-file-before-upload
Upvotes: 0