File upload control size
hi,
i want to get the size of upload file using js.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Blocked AccountPosted Nov 25, 2008, 1:06 AM
Hi,
This code is for those people who are using ActiveX object and knows that browser will support the below script.
<script language=”javascript” type=”text/javascript”>
var objFSO ;
try
{
objFSO = new ActiveXObject(“Scripting.FileSystemObject”);
}
catch(err)
{
alert(err.message);
alert(err.number);
}
function CheckExtention(el) // pass Upload File object’s ClientID here
{
var myel= document.getElementById(el);
var file;
var path = myel.value;
//alert(path);
file = objFSO.getFile(path);
var size;
size = file.size ; // This size will be in Bytes
// We are converting it to KB as below
alert(‘File Size is : ‘ + file.size /1024 +‘ KB’);
}
script>