check file size before post

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
 
E

Eliyahu Goldin

You can't access the filesysytem on the client unless you want to use java
applets or ActiveX controls.

Eliyahu
 
G

Guest

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
 
B

bruce barker

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
 
G

Guest

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
 
N

nicholas

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
 
S

Sayed Hashimi

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
 

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,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top