472,334 Members | 2,214 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,334 software developers and data experts.

Error in file upload

I am trying to upload a file to the webserver through my
asp.net application. The file upload works fine for files
below 50 MB size because i have set the maxrequestlength
property of the <httpruntime> in the machine.config file
as 51200KB. whenever the user tries to upload a file which
is more than 51200KB then, a blank page with DNS error is
shown as soon as the user hits the submit button.
I want to be able to display an error message to the user
if the file size is greater than 50 MB. How do i catch
this error? I have tried using the try catch block in the
submit button onClick() event, but no use. Please post me
detailed answer.
Thanks in advance.

Nov 18 '05 #1
4 2197
"Amar" <an*******@discussions.microsoft.com> wrote in message
news:0a****************************@phx.gbl...
I am trying to upload a file to the webserver through my
asp.net application. The file upload works fine for files
below 50 MB size because i have set the maxrequestlength
property of the <httpruntime> in the machine.config file
as 51200KB. whenever the user tries to upload a file which
is more than 51200KB then, a blank page with DNS error is
shown as soon as the user hits the submit button.
I want to be able to display an error message to the user
if the file size is greater than 50 MB. How do i catch
this error? I have tried using the try catch block in the
submit button onClick() event, but no use. Please post me
detailed answer.


If you are using a RUNAT=SERVER form with an <input type=file /> style
control, you really only have access to the stream of a posted file after
the file has been fully sent. What you'd have to do is permit the clients to
send files larger than the max, and then measure the file only after it has
been fully posted.

The maxrequestlength property is a bit of a security measure, and can't
really be bypassed even for file measuring purposes, not even with try/catch
blocks. For RFC 1867 uploads, I still use .asp a lot of the time, as it is a
bit more permissive about them.

Richard
Nov 18 '05 #2
Assuming you use the HTMLInputFile Control to choose your
file to upload then you can do something like this,

HttpPostedFile file = fileUpload.PostedFile;
int fileLen = file.ContentLength;

fileUpload is the HTMLInputFile control name ...

Thanks,
-Shan

-----Original Message-----
I am trying to upload a file to the webserver through my
asp.net application. The file upload works fine for files
below 50 MB size because i have set the maxrequestlength
property of the <httpruntime> in the machine.config file
as 51200KB. whenever the user tries to upload a file whichis more than 51200KB then, a blank page with DNS error is
shown as soon as the user hits the submit button.
I want to be able to display an error message to the user
if the file size is greater than 50 MB. How do i catch
this error? I have tried using the try catch block in the
submit button onClick() event, but no use. Please post me
detailed answer.
Thanks in advance.

.

Nov 18 '05 #3
Sorry didnt see Richards reply ! Richard is probably
right !

Thanks,
-Shan

-----Original Message-----
"Amar" <an*******@discussions.microsoft.com> wrote in messagenews:0a****************************@phx.gbl...
I am trying to upload a file to the webserver through my
asp.net application. The file upload works fine for files below 50 MB size because i have set the maxrequestlength
property of the <httpruntime> in the machine.config file
as 51200KB. whenever the user tries to upload a file which is more than 51200KB then, a blank page with DNS error is shown as soon as the user hits the submit button.
I want to be able to display an error message to the user if the file size is greater than 50 MB. How do i catch
this error? I have tried using the try catch block in the submit button onClick() event, but no use. Please post me detailed answer.
If you are using a RUNAT=SERVER form with an <input

type=file /> stylecontrol, you really only have access to the stream of a posted file afterthe file has been fully sent. What you'd have to do is permit the clients tosend files larger than the max, and then measure the file only after it hasbeen fully posted.

The maxrequestlength property is a bit of a security measure, and can'treally be bypassed even for file measuring purposes, not even with try/catchblocks. For RFC 1867 uploads, I still use .asp a lot of the time, as it is abit more permissive about them.

Richard
.

Nov 18 '05 #4
Thanks Richard and Shan,
I am using the HtmlInputFile control.But Shan where
exactly do you want me to put in your code? becoz,after
the user selects a file to upload and hits Submit, then
the flow of the code does not go into the OnClick() event
of the submit button, if the filesize is > 50 Mb.I checked
this by setting a breakpoint on the first line of the
OnClick event. The aspx page just shows a DNS error page.
Is there a way, that i can check the size of the file
before the user clicks submit maybe.
-----Original Message-----
Assuming you use the HTMLInputFile Control to choose your
file to upload then you can do something like this,

HttpPostedFile file = fileUpload.PostedFile;
int fileLen = file.ContentLength;

fileUpload is the HTMLInputFile control name ...

Thanks,
-Shan

-----Original Message-----
I am trying to upload a file to the webserver through my
asp.net application. The file upload works fine for filesbelow 50 MB size because i have set the maxrequestlength
property of the <httpruntime> in the machine.config file
as 51200KB. whenever the user tries to upload a file

which
is more than 51200KB then, a blank page with DNS error isshown as soon as the user hits the submit button.
I want to be able to display an error message to the userif the file size is greater than 50 MB. How do i catch
this error? I have tried using the try catch block in thesubmit button onClick() event, but no use. Please post medetailed answer.
Thanks in advance.

.

.

Nov 18 '05 #5

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

Similar topics

3
by: Amy Kimber | last post by:
Hello, I have a file upload page, and I've had it working fine, it was beautiful :-) Anyway, the powers that be moved hosts... and it doesn't...
7
by: Joe | last post by:
I have an upload file operation in the web application. UploadForm.asp is the form, and UploadAction.asp is the form processing. ...
6
by: Paul | last post by:
Hi there, When adding a "File Field" HTML control to an aspx page to facilitate file uploading, the following occurs: 1. You select a file...
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! ...
0
by: ruju00 | last post by:
I am getting an error in Login() method of the following class FtpConnection public class FtpConnection { public class FtpException : Exception...
2
by: Paolo | last post by:
Hi to all, I have an error that drove me crazy. Try the following page that should only allow to upload a file: <html...
0
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport...
1
by: chrisj | last post by:
I'm using freeASPupload and got some assistance integrating to a Member script. It works successfully. In this modified version there are two...
4
rahulephp
by: rahulephp | last post by:
i think i am missing something in the below script: It shows error an do not upload files to destination: Let me know how to solve this: ...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

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.