473,503 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

check file size before upload

hi all,

In asp.net 2.0 there is a limit on file size upload of 4MB. I know this
limit can be increased in web.config file.
Is there any way to check the file size before upload ?
if user is trying to upload file size more than 4MB then just display a
message that file size is too big and can't be uploaded.

thanks
Jul 27 '06 #1
3 30185
You can find HttpPostedFile object in FileUpload control.

Such as,
HttpPostedFile MyFile;
int FileLen;
System.IO.Stream MyStream;

MyFileCollection = Request.Files;
MyFile = MyFileCollection[0];

FileLen = MyFile.ContentLength;

Now, you can check file length and display some messages to alert user.

Sincerely,
simida

puja wrote:
hi all,

In asp.net 2.0 there is a limit on file size upload of 4MB. I know this
limit can be increased in web.config file.
Is there any way to check the file size before upload ?
if user is trying to upload file size more than 4MB then just display a
message that file size is too big and can't be uploaded.

thanks
Jul 28 '06 #2
thanks a lot

I got it solved using contentLength property. :)
"simida" <yo**********@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
You can find HttpPostedFile object in FileUpload control.

Such as,
HttpPostedFile MyFile;
int FileLen;
System.IO.Stream MyStream;

MyFileCollection = Request.Files;
MyFile = MyFileCollection[0];

FileLen = MyFile.ContentLength;

Now, you can check file length and display some messages to alert user.

Sincerely,
simida

puja wrote:
>hi all,

In asp.net 2.0 there is a limit on file size upload of 4MB. I know this
limit can be increased in web.config file.
Is there any way to check the file size before upload ?
if user is trying to upload file size more than 4MB then just display a
message that file size is too big and can't be uploaded.

thanks

Jul 28 '06 #3
Can youplease explain where you have included this code? 'Cos fo all
postback event, the file starts upload before checking the size.

I use ASP.Net version 1.1 and is there any way to check the file size
before uploading (though Javascript)?

Thanks

Gowthami

simida wrote:
You can find HttpPostedFile object in FileUpload control.

Such as,
HttpPostedFile MyFile;
int FileLen;
System.IO.Stream MyStream;

MyFileCollection = Request.Files;
MyFile = MyFileCollection[0];

FileLen = MyFile.ContentLength;

Now, you can check file length and display some messages to alert user.

Sincerely,
simida

puja wrote:
hi all,

In asp.net 2.0 there is a limit on file size upload of 4MB. I know this
limit can be increased in web.config file.
Is there any way to check the file size before upload ?
if user is trying to upload file size more than 4MB then just display a
message that file size is too big and can't be uploaded.

thanks
Aug 25 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5448
by: tgundeck | last post by:
Does anyone know how I can check the file size of photos or any file type in JavaScript? I'm allowing users to store photos in my web page using the input type = file tag, but need to limit the...
1
1494
by: Poppy | last post by:
I have written some code which uploads a file. Before I upload the file I would like to check on the file size. If its below a certain limit I want to upload it else present the user with an...
4
2588
by: lawrence | last post by:
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...
6
3133
by: nicholas | last post by:
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...
6
194049
by: monki_sf | last post by:
Was wondering if anyone knew of way to validate an images file size using javascript - i.e keeping the upload to say 500k. I've seen scripts to validate the dimensions - but nothing for the actual...
3
13112
by: Jefferis NoSpamme | last post by:
Hello all, I'm trying to limit the file size to 1 meg on upload of image files and I am trying a script from javascript internet, but it is giving me errors on IE ² is null or not an object ³...
13
4767
by: marfola | last post by:
I’m trying to find the file size using javascript, before it get uploaded into the server using the following Javascript (I don’t want to use ActiveX because of compatibility problem). function...
6
1943
by: gyap88 | last post by:
hello, is there a command that returns the file size of a specific file as an integer
3
8246
Frinavale
by: Frinavale | last post by:
Hi there! I'm hoping that someone knows how to check the size of a file before it is uploaded to the server using JavaScript. I have seen suggested solutions using an ActiveX control to check...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5596
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4689
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3170
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
401
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.