Upload file Check file size

Discussion in 'ASP .Net' started by lawrence, Jun 10, 2004.

  1. lawrence

    lawrence Guest

    Using <INPUT type"file" runat="server"> to upload a file. When the
    file size is too large I get a "page cannot be display" error. Thats
    cool I'm down with that. But is there a way to check for file size
    (client or server side), so that error doesn't occur?

    Thanks
    --Dietrich
     
    lawrence, Jun 10, 2004
    #1
    1. Advertising

  2. Not that i am aware.
    The file size upload is a server restriction and you can change it.
    Also i think that error is one of the standard error pages from IIS server.
    So you can modify it.

    George.

    "lawrence" <> wrote in message
    news:...
    > Using <INPUT type"file" runat="server"> to upload a file. When the
    > file size is too large I get a "page cannot be display" error. Thats
    > cool I'm down with that. But is there a way to check for file size
    > (client or server side), so that error doesn't occur?
    >
    > Thanks
    > --Dietrich
     
    George Ter-Saakov, Jun 10, 2004
    #2
    1. Advertising

  3. On Thu, 10 Jun 2004 13:39:31 -0400, George Ter-Saakov <>
    wrote:

    > Not that i am aware.
    > The file size upload is a server restriction and you can change it.
    > Also i think that error is one of the standard error pages from IIS
    > server.
    > So you can modify it.
    >
    > George.
    >
    > "lawrence" <> wrote in message
    > news:...
    >> Using <INPUT type"file" runat="server"> to upload a file. When the
    >> file size is too large I get a "page cannot be display" error. Thats
    >> cool I'm down with that. But is there a way to check for file size
    >> (client or server side), so that error doesn't occur?
    >>
    >> Thanks
    >> --Dietrich

    >
    >


    Yes, you can change it to a larger number:

    http://www.tek-tips.com/gfaqs.cfm/pid/855/fid/3217

    please excuse the annoying flyover ad on that page :)

    I also agree, I don't know of any JS that can detect that, unless it had
    extremely lax browser privileges, which is a very rare setup you'd have to
    make sure is there (change client's browser settings). I don't know if
    you can somehow create an HttpModule to intercept the incoming file before
    the server check is done by ASP.NET (note this is not IIS throwing the
    error, but ASP.NET as it's an ASP.NET setting).

    --
    Craig Deelsnyder
    Microsoft MVP - ASP/ASP.NET
     
    Craig Deelsnyder, Jun 10, 2004
    #3
  4. lawrence

    dietrich Guest

    ASP.NET throws the error? What is actually happening. Is some sort of
    header with file size info being read, or is the file being streamed,
    and then chokes at the set limit?


    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    dietrich, Jun 10, 2004
    #4
  5. On Thu, 10 Jun 2004 12:16:34 -0700, dietrich <> wrote:

    > ASP.NET throws the error? What is actually happening. Is some sort of
    > header with file size info being read, or is the file being streamed,
    > and then chokes at the set limit?
    >
    >
    > *** Sent via Devdex http://www.devdex.com ***
    > Don't just participate in USENET...get rewarded for it!


    Well, if you follow that link, you'll notice that it's a setting you can
    put in web.config, which is ASP.NET specific. It was introduced to
    prevent malicious uploading or be able to conserve your bandwidth (enforce
    file sizes).

    It is possible IIS has a limit of its own, and maybe something you can set
    also, which would be checked first. I can't remember tho, when you see
    this error page, if it's a result of IIS giving the error, or ASP.NET
    playing dumb and returning a 500....

    I'm not familiar with all the internals of exactly what goes on in this
    scenario. The times I've hit it, it hit the ASP.NET limit and errored
    out, so I was able to up the size and get it to go through.

    --
    Craig Deelsnyder
    Microsoft MVP - ASP/ASP.NET
     
    Craig Deelsnyder, Jun 10, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2FyYXY=?=

    Upload a file without file Upload control - ASP.Net

    =?Utf-8?B?U2FyYXY=?=, Aug 2, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    2,581
    Bruce Barker
    Aug 3, 2005
  2. Heather Fraser
    Replies:
    0
    Views:
    664
    Heather Fraser
    Jul 5, 2004
  3. Replies:
    1
    Views:
    968
    Gabriel Genellina
    Nov 25, 2006
  4. Jason Cavett

    Preferred Size, Minimum Size, Size

    Jason Cavett, May 23, 2008, in forum: Java
    Replies:
    5
    Views:
    12,733
    Michael Jung
    May 25, 2008
  5. Prakash
    Replies:
    3
    Views:
    491
    Ray at
    Nov 12, 2003
Loading...

Share This Page