function A()
{
var oas = new ActiveXObject("Scripting.FileSystemObject");
var d = document.a.b.value;
var e = oas.getFile(d);
var f = e.size;
alert(f + " bytes");
}
</script>
</head>
<body>
<form name="a">
<input type="file" name="b">
<input type="button" name="c" value="SIZE" onClick="A();">
</form>
</body>
</html>
Thanks Imran - so applying this to my forms validation should look like this right?
- <script language=javascript>
-
extArray = new Array(".jpg", ".jpeg",".gif"); //".png", , ".gif"
-
-
function callCancel()
-
{
-
document.frmlisting.action="listing_list.php?cityid=<?=$cityid?>&c_id=<?=$c_id?>";
-
document.frmlisting.submit();
-
}
-
-
function callSave()
-
{
-
var oas = new ActiveXObject("Scripting.FileSystemObject");
-
var d = document.frmlisting.txtlistingimage.value;
-
var e = oas.getFile(d);
-
var f = e.size;
-
alert(f + "500000");
-
}
-
{
-
if(!isCurrency(document.frmlisting.txtlistingprice.value)){
-
alert("Price: Incorrect data");
-
document.frmlisting.txtlistingprice.select();
-
return;
-
}
-
if(isBlank(document.frmlisting.txtlistingtitle.value)){
-
alert("Title is Required");
-
document.frmlisting.txtlistingtitle.focus();
-
return;
-
}
-
if(!isBlank(document.frmlisting.txtlistingimage.value)){
-
if(!isValidFile(document.frmlisting.txtlistingimage.value)){
-
alert("Selected file is not a vaild image type. \nPlease select "+ (extArray.join(" ").toUpperCase())+ " files. ");
-
document.frmlisting.txtlistingimage.select();
-
return;
-
}
-
}
-
if(isBlank(document.frmlisting.txtlistingemail.value)){
-
alert("Email is Required");
-
document.frmlisting.txtlistingemail.select();
-
return;
-
-
}
-
if(!isEmail(document.frmlisting.txtlistingemail.value)){
-
alert("Email: Incorrect data");
-
document.frmlisting.txtlistingemail.select();
-
return;
-
}
-
-
document.frmlisting.action="listingsubmit.php";
-
document.frmlisting.submit();
-
}
-
</script>
HTML Would be
[HTML]<Input type="file" name="txtlistingimage" style="WIDTH: 275px; HEIGHT: 20px" size=39 maxlength=100>
<input type="button" class="btn_text" value="Preview" onclick="javascript
:callSave();" style="border:solid-1px; color: #333333 ">[/HTML]