-1

i am using http://bojanmauser.from.hr/bvalidator/ this script to validate my form, now i am stack with a problem, want to set max file limit for image file upload. but i am unsuccessful everytime, can anybody help me to get rid of this, advance thanx to all, who is reading this discussion and give a helping a hand to solve this problem...

Votes + Comments
a correct answer has been given to you - you need to say "THANK YOU!" and mark your thread as "Solved!"
3
Contributors
7
Replies
21
Views
4 Years
Discussion Span
Last Post by Troy III
0

i dont know how to validate/limit the image file size using the bvalidator, thats why i am using a code to get the file size, here is the code

<script type="text/javascript" src="js/jquery-1.9.1.js"></script>
<script language="javascript">
//Code Starts
$(document).ready(function() {
   $("#photo").change(function () 
   { 
     var iSize = ($("#photo")[0].files[0].size / 1024); 
     if (iSize / 1024 > 1) 
     { 
        if (((iSize / 1024) / 1024) > 1) 
        { 
            iSize = (Math.round(((iSize / 1024) / 1024) * 100) / 100);
            $("#photoSize").html( iSize ); 
        }
        else
        { 
            iSize = (Math.round((iSize / 1024) * 100) / 100)
            $("#photoSize").html( iSize ); 
        } 
     } 
     else 
     {
        iSize = (Math.round(iSize * 100) / 100)
        $("#photoSize").html( iSize ); 
     }    
  }); 
});

//Code Ends
</script>



Select file : <input type="file" id="photo" />
<br/><br/>
File Size is : <b><label id="photoSize" /></b>

i am trying to get the size in input box, then i will validate the value with bvalidator, but if i changed the label into a input box its not display the size, help me, what can i do at this situation?

0

thanx again for your reply, sorry, but i am not good at javascript, if you show me in code, then it will be better for me to understand.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.