Upload file Check file size

L

lawrence

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
 
G

George Ter-Saakov

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.
 
C

Craig Deelsnyder

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.

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).
 
D

dietrich

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!
 
C

Craig Deelsnyder

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top