473,406 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Fileupload problem with files larger than 1MB

Hi

I have a problem with the uploading of files larger than 1MB.

My upload code look like this:

If Not fUpload.PostedFile Is Nothing And
fUpload.PostedFile.ContentLength > 0 Then
fn = Path.GetFileName(fUpload.PostedFile.FileName)
SaveLocation = Server.MapPath("hjplusupload") + "\" + fn

Try
fUpload.PostedFile.SaveAs(SaveLocation)
lblMessages.Text = "The file has been uploaded to: " &
SaveLocation
Catch ex As Exception
lblMessages.Text = "Error: " + ex.Message
End Try
Else
lblMessages.Text = "Please enter a file to upload."
End If

And I have added the following to my web.config:
<httpRuntime executionTimeout="3600" maxRequestLength="10000" />

However when I try to upload files above 1MB the server just returns a
standard IIS "Cannot Find Server - page cannot be displayed" error -
no error from .NET.

I have tried adjusting the maxRequestLength - but nothing seems to
work.
The server is a Win2K.
Nov 17 '05 #1
2 3100
The first thing you need to do is to enable IE to give you the actual error
message:

Tools|Internet Options|Advanced - uncheck "Show Friendly HTTP Error
messages"

That should help you with future error messages.

Second, you need to make the same change in your machine.config file that
you made in the web.config file. The settings in the machine.config file
override any application-specific settings.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
The more I learn, the less I know.

"grimBeast" <cb@bbit.dk> wrote in message
news:20*************************@posting.google.co m...
Hi

I have a problem with the uploading of files larger than 1MB.

My upload code look like this:

If Not fUpload.PostedFile Is Nothing And
fUpload.PostedFile.ContentLength > 0 Then
fn = Path.GetFileName(fUpload.PostedFile.FileName)
SaveLocation = Server.MapPath("hjplusupload") + "\" + fn

Try
fUpload.PostedFile.SaveAs(SaveLocation)
lblMessages.Text = "The file has been uploaded to: " &
SaveLocation
Catch ex As Exception
lblMessages.Text = "Error: " + ex.Message
End Try
Else
lblMessages.Text = "Please enter a file to upload."
End If

And I have added the following to my web.config:
<httpRuntime executionTimeout="3600" maxRequestLength="10000" />

However when I try to upload files above 1MB the server just returns a
standard IIS "Cannot Find Server - page cannot be displayed" error -
no error from .NET.

I have tried adjusting the maxRequestLength - but nothing seems to
work.
The server is a Win2K.

Nov 17 '05 #2
do you have more than one machine.config?

"Christian Bennich" <cb@bbit.dk> wrote in message
news:um**************@TK2MSFTNGP12.phx.gbl...
Hi Kevin

Thanks for your reply.

I have tried all of your suggestions, but still nothing works.

It seems that ASP.NET partly doesn't care about the values that I put in
either the web.config or the machine.config.

If I set maxRequestLength=10 then it behaves almost correcly. Now I
can't upload a small 120K file, but I still get the DNS error. As soon
as I adjust the maxRequestLength to more than 1000 then it fucks up, and
I can only upload files below 1000K - NOT GOOD :-(

Any other help would be greatly appriciated.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #3

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

Similar topics

8
by: VB Programmer | last post by:
I am using a FileUpload control (ASP.NET 2.0). How do I check the length of the file in bytes BEFORE I let them upload it? I believe my code checks now AFTER... If...
4
by: ad | last post by:
I use a FileUpload control to upload a text file to web server. If the size of the file is larger (about 9M), the page will result in an "Can't find page" error after I press a button to access the...
12
by: Phil Z. | last post by:
After migrating an ASP.NET 1.1 application to 2.0 we were getting "Cannot access a closed file" errors when uploading. I found a number of post on the subject and have since moved from using an...
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 xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">...
4
by: Dave | last post by:
If you had a FileUpload control inside of a FormView...how would you use FindControl to access the FileUpload properties? Let me just say that...
1
by: Harinath | last post by:
Hi All, I am working on a portal using .net2.0. In one of my page, i have FileUpload control. I am doing some server side validation for form fields in general. if there is any validation...
1
by: nicknack | last post by:
Hello. I would like to give my user the option to browse his files (like the simple fileUpload control do) and after selecting the file (and when the fileUpload control hold in his text box the...
2
by: =?Utf-8?B?UGF1bA==?= | last post by:
I have a gridview with 2 columns. One column is a BoundColumn to a part number (string). One column is an ItemTemplate with a FileUpload control. There can be multiple rows (i.e. part numbers)...
2
by: miladhatam | last post by:
hi i want make a page that users can upload their picture but my problem : how can i dynamically add this control cos i want that they can upload every pic they have and like gmail if you browse...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.