<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<script language="javascript" type="text/javascript">
function getFileSize (fileName) {
if (document.layers) {
if (navigator.javaEnabled()) {
var file = new java.io.File(fileName);
if (location.protocol.toLowerCase() != 'file:') {
netscape.security.PrivilegeManager.enablePrivilege('UniversalFileRead');
}
return file.length();
} else {
return -1;
}
}
else if (document.all) {
window.oldOnError = window.onerror;
window.onerror = function (err) {
if (err.indexOf('utomation') != -1) {
alert('file access not possible');
return true;
} else {
return false;
}
}
var fso = new ActiveXObject('Scripting.FileSystemObject');
var file = fso.GetFile(fileName);
window.onerror = window.oldOnError;
return file.Size;
}
}
function valiate(form) {
var size;
size = getFileSize(form.file.value);
alert ("File Size is : " + size);
}
</script>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data" name="form1" onSubmit="valiate(this)">
<input type="file" name="file">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<script language="javascript" type="text/javascript">
function getFileSize (fileName) {
if (document.layers) {
if (navigator.javaEnabled()) {
var file = new java.io.File(fileName);
if (location.protocol.toLowerCase() != 'file:') {
netscape.security.PrivilegeManager.enablePrivilege('UniversalFileRead');
}
return file.length();
} else {
return -1;
}
}
else if (document.all) {
window.oldOnError = window.onerror;
window.onerror = function (err) {
if (err.indexOf('utomation') != -1) {
alert('file access not possible');
return true;
} else {
return false;
}
}
var fso = new ActiveXObject('Scripting.FileSystemObject');
var file = fso.GetFile(fileName);
window.onerror = window.oldOnError;
return file.Size;
}
}
function valiate(form) {
var size;
size = getFileSize(form.file.value);
alert ("File Size is : " + size);
}
</script>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data" name="form1" onSubmit="valiate(this)">
<input type="file" name="file">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
'IT_Programming > JavaScript' 카테고리의 다른 글
브라우저, 스타일XP를 무시한채로 resizeTo() 하기 (0) | 2006.04.29 |
---|---|
다중셀렉트간 항목다중이동 및 순서설정 (0) | 2006.04.29 |
아이디 비밀번호 공간체크 / 특수문자 체크 (0) | 2006.04.29 |
[스크랩] History 객체 (0) | 2006.04.28 |
[스크랩] String 객체 (0) | 2006.04.27 |