<html>
<head>
<title>Check the Size of a File -- Javascript</title>
<script language="JavaScript">
function CheckFileSize()
{
var objSize = new ActiveXObject("Scripting.FileSystemObject");
var strFileName = objSize.getFile(document.frmFileUpload.strFile.value);
var SizeOfFile = strFileName.size;
alert(SizeOfFile + " bytes");
}
</script>
</head>
<body>
<form name="frmFileUpload">
<input type="file" name="strFile">
<input type="button" name="btnSize" value="Show file size" onClick="CheckFileSize();">
</form>
</body>
</html>
The above code snippet will work only if ActiveX is supported @ the client end.
<head>
<title>Check the Size of a File -- Javascript</title>
<script language="JavaScript">
function CheckFileSize()
{
var objSize = new ActiveXObject("Scripting.FileSystemObject");
var strFileName = objSize.getFile(document.frmFileUpload.strFile.value);
var SizeOfFile = strFileName.size;
alert(SizeOfFile + " bytes");
}
</script>
</head>
<body>
<form name="frmFileUpload">
<input type="file" name="strFile">
<input type="button" name="btnSize" value="Show file size" onClick="CheckFileSize();">
</form>
</body>
</html>
The above code snippet will work only if ActiveX is supported @ the client end.
Comments
Can't we check d file size by any other means, if we don hav ActiveX on d comp??
- Sesh