check file size before post

  • Thread starter Thread starter nicholas
  • Start date Start date
N

nicholas

when I upload a file, I can set in my code not to save it if the file size
is too large.
But then the user has allready been waiting a few minutes to upload his
file, as this can only be controlled once it is uploaded.

I would like to say to the user the file is too large before it uploads it.

any ideas?
thx
-- using vb.net on asp.net page
 
You can't access the filesysytem on the client unless you want to use java
applets or ActiveX controls.

Eliyahu
 
hi

you can get your page size
int fileSize = Page.Request.Files[0].ContentLength;
so if your page content is bigger that a value put a message not to upload
the file.

Cheers
 
this will not work, as the file is already uploaded by this time.

as noted, the only option is an active/x control (java applet will not
work).

-- bruce (sqlwork.com)



Psycho said:
hi

you can get your page size
int fileSize = Page.Request.Files[0].ContentLength;
so if your page content is bigger that a value put a message not to upload
the file.

Cheers

nicholas said:
when I upload a file, I can set in my code not to save it if the file size
is too large.
But then the user has allready been waiting a few minutes to upload his
file, as this can only be controlled once it is uploaded.

I would like to say to the user the file is too large before it uploads it.

any ideas?
thx
-- using vb.net on asp.net page
 
yes, your are right. only with activex can find on client machine the file
length.

bruce barker said:
this will not work, as the file is already uploaded by this time.

as noted, the only option is an active/x control (java applet will not
work).

-- bruce (sqlwork.com)



Psycho said:
hi

you can get your page size
int fileSize = Page.Request.Files[0].ContentLength;
so if your page content is bigger that a value put a message not to upload
the file.

Cheers

nicholas said:
when I upload a file, I can set in my code not to save it if the file size
is too large.
But then the user has allready been waiting a few minutes to upload his
file, as this can only be controlled once it is uploaded.

I would like to say to the user the file is too large before it uploads it.

any ideas?
thx
-- using vb.net on asp.net page
 
ok, thx everyone !

Psycho said:
yes, your are right. only with activex can find on client machine the file
length.

bruce barker said:
this will not work, as the file is already uploaded by this time.

as noted, the only option is an active/x control (java applet will not
work).

-- bruce (sqlwork.com)



Psycho said:
hi

you can get your page size
int fileSize = Page.Request.Files[0].ContentLength;
so if your page content is bigger that a value put a message not to upload
the file.

Cheers

:

when I upload a file, I can set in my code not to save it if the
file
size
is too large.
But then the user has allready been waiting a few minutes to upload his
file, as this can only be controlled once it is uploaded.

I would like to say to the user the file is too large before it
uploads
it.
any ideas?
thx
-- using vb.net on asp.net page
 
Nicholas,

The machine.config file defines the <httpRuntime> element that can be
used to control the max file size. For example,

<!-- set max size to 60 megs and max timeout to 60 minutes -->
<httpRuntime executionTimeout="3600" maxRequestLength="61440" />

You can override this in your own application's web.config file so
that it only affects your application and not all applications.

If a user attempts to upload a file greator than the max size, the
browser will immediately give the user an error message.
Unfortunately the error message is not user friendly. If you can live
with that, that is the easiest thing to do.


sayed
 
Back
Top