0

I am trying to find the size of file but it is display nothing please help me

  <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<style>
div {
    padding: 1px;
    border-bottom: ridge;
    width: 600px
}

this function is use to check whether or not user enter a image.

</style>
<script language="javascript">
    function checkImage() {
        if (document.form2.path.value == "") {
            alert("Enter path of Image");
            return false;
        }
        return true;
    };

this function is not working properly here i am try to check the size of file but it is not working

    function checkSize(){
        var images=document.form2.path.value;
        if (images != "") {
    var f =document.getElementById("loadImage").files[0];           
            alert(f.size);
            return false;
        }
    }
</script>
</head>
<body>
    <center>
        <div>
            <h2>Image Management Utility</h2>
        </div>
    </center>
    <br>
    <br>

    <br>
    <form name="form2" action="images" method="post" onsubmit="return checkImage()">
        <table width="800" align="center">
            <tr>
                <td>Please select an image file (maximum size 1MB)</td>
            </tr>
            <tr>
                <td><input type="file" name="path" id="loadImage" /></td>
                <td align="right"><input type="submit" name="submit"
                    value="submit" onclick="return checkSize()" /></td>
            </tr>
        </table>
    </form>
</body>
</html>
BenMorel
  • 34,448
  • 50
  • 182
  • 322
user3370281
  • 121
  • 1
  • 9

0 Answers0