Tuesday, April 17, 2012

Using javascript check uploaded file size in PHP

<script language="javascript" type="text/javascript">
function aditya(source, args)
{
//alert('hi');
arguments.isvalid = false;
fileupload = document.getElementById('file1');
file=fileupload.files[0];
if (file.size<1048576)
{
args.IsValid = true;
return true;
}
else
{
alert("file size is greater than 1048576 ");
args.IsValid = false ;
return false;
}

}
</script>
<form name="upload" action="" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file1">
<input type="submit" name="Submit" value="Upload" onclick="return aditya();">
</form>

No comments:

Post a Comment