var strFileName= document.getElementById("FUAttachContract").value;
var objFSO = new ActiveXObject("Scripting.FileSystemObject");
var e = objFSO.getFile(strFileName);
var fileSize = e.size;
if (fileSize > 2097152) {
alert('size more than 2MB');
}
Marked as answer by starmgm on Feb 21, 2012 09:13 AM
Hi
You really have found correct ansfer, but keep in mind that:
1. Creating of FileSystelOblect will show alert, asking for permission. In can't be avoided
2. Your code will work only in InternetExplorer
Good Luck
O. Zhelezov
Marked as answer by starmgm on Feb 21, 2012 06:26 PM
starmgm
Member
58 Points
53 Posts
get file size for uploadfile control using javascript?
Feb 21, 2012 08:51 AM|LINK
hey i have uploadfile control i want to get the uploaded file size using javascript and show the size on alert message? may anyone help??
niksv
Contributor
5925 Points
1115 Posts
Re: get file size for uploadfile control using javascript?
Feb 21, 2012 09:09 AM|LINK
http://www.webdeveloper.com/forum/showthread.php?t=29776
check the 4th reply
starmgm
Member
58 Points
53 Posts
Re: get file size for uploadfile control using javascript?
Feb 21, 2012 09:13 AM|LINK
var strFileName= document.getElementById("FUAttachContract").value; var objFSO = new ActiveXObject("Scripting.FileSystemObject"); var e = objFSO.getFile(strFileName); var fileSize = e.size; if (fileSize > 2097152) { alert('size more than 2MB'); }Zhelezov
Member
278 Points
65 Posts
Re: get file size for uploadfile control using javascript?
Feb 21, 2012 09:54 AM|LINK
Hi
You really have found correct ansfer, but keep in mind that:
1. Creating of FileSystelOblect will show alert, asking for permission. In can't be avoided
2. Your code will work only in InternetExplorer
Good Luck
O. Zhelezov
AneevJohn
Member
140 Points
52 Posts
Re: get file size for uploadfile control using javascript?
Feb 21, 2012 10:53 AM|LINK
Hi,
Yes this will work better for you.
Aneev John
starmgm
Member
58 Points
53 Posts
Re: get file size for uploadfile control using javascript?
Feb 21, 2012 06:26 PM|LINK
thank you all