Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Check file-size using jQuery without uploading file

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 581
    Comment on it

    A simple code snippet for checking the file-size of a file before uploading it. It will not only help to save time but also network resource as we can implement the file check at the initial point only.

    The current code allows the user to select a file and then it shows an alert showing the file-size of the file after selection. The code utilizes jQuery to find the file-size.

    <script src="">
    <form action="upload" enctype="multipart/form-data" method="post">
    Upload File:
    <input id="filesize" type="file" name="file" />
    <input type="submit" value="Upload" />
    <script type="text/javascript">
        $('#filesize').bind('change', function() {
            alert('This file size is: ' + this.files[0].size/1024/1024 + "MB");

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: