how can I get file size at client side using actionscript and javascript
Thanks a lot
What you are looking for is the FileReference class.
Upon the user 'selecting' the file they wish to upload, the properties of that file is populated in the FileReference instance. Then accessing it, is simply to call:
fileRef.size()
Below is a code snippet to illustrate how to use FileReference class.
var fileRef:FileReference= new FileReference();
fileRef.browse([new FileFilter("Images", "*.jpg;*.gif;*.png")]);
fileRef.addEventListener(Event.SELECT, onFileSelected);
function onFileSelected(e:Event):void
{
trace("Size of file is:"+fileRef.size());
}
You could try looking at the numerous flash based file upload methods and see if any give you back the actual file sizes of each file in the queue.
For example SWFUpload may have this functionality but I've not tested it.
we can use this activeX code . But it will run only in few browsers
<html>
<head>
<script>
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");
}
</script>
</head>
<body>
<form name="upload">
<input type="file" name="file">
<input type="button" value="Size?" onClick="getSize();">
</form>
</body>
</html>
Check this URL How can you determine the file size in JavaScript? and also look at this URL http://devpro.it/FileReference/