Possible to check for file size in form validation?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pete Bennett

    Possible to check for file size in form validation?

    Folks,

    I want to allow people to upload files to my site. I wondered, is there
    a way in Javascript to limit the size of the file they are able to
    submit?

    Cheers
    --
    Kind Regards,
    Pete Bennett

    future implications limited (UK)

    mobile: 0702 11 16 2 47 (+44 7990 594 088 from outside UK)
    office: 0870 74 24 0 24 (+44 8707 424 024 from outside UK)


    www : http://www.futureimplications.com


  • Janwillem Borleffs

    #2
    Re: Possible to check for file size in form validation?


    "Pete Bennett" <pmb1@futureim. demon.co.uk> schreef in bericht
    news:idY$iZApFP N$Ew5u@futureim .demon.co.uk...[color=blue]
    > Folks,
    >
    > I want to allow people to upload files to my site. I wondered, is there
    > a way in Javascript to limit the size of the file they are able to
    > submit?
    >[/color]

    Short answer: No, you should handle this on the server.

    Long answer: Not reliable. With IE you could do something like:

    function checkSize(files pec) {
    var fso, f, s;
    fso = new ActiveXObject(" Scripting.FileS ystemObject");
    f = fso.GetFile(fil espec);
    s = f.size;
    // Do something with var s
    }

    But this can easily be comprimised by the browser's security settings or the
    usage of another browser or platform.


    JW



    Comment

    Working...