1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

File Size Validation

Discussion in 'JavaScript and AJAX' started by anis, Apr 21, 2007.

  1. anis

    anis New Member

    Joined:
    Apr 21, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hello All,
    I have 125kb file on my system.I want to validate file size not more than 80kb in JavaScript. when i upload a file.Pls suggest me javascript code for this file size validation.
    thanks.
     
  2. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    Javascript does not have the ability to do that (for security reasons). For IE you would need to have the user accept an appropriate Active-X control.
     
  3. anis

    anis New Member

    Joined:
    Apr 21, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hello,
    Is it possible file size validation in PHP using AJAX. If yes pls help me and reply soon.
     
  4. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    Either you'll need to use an ActiveX control or you'll have to use a server-side validation.
    You cannot validate filesize using AJAX 'cause that'll require posting the file, which again is not possible due to JavaScript's limited filesystem abilities.

    You can also try the same with an applet, which will ensure cross-platform functioning.
     

Share This Page