File Upload - Uploading files greater than 4 MB

I use 2.0 with VS 2008

In my code I have put a file upload limit of 1 MB. But if I try uploading files greater than 4 MB, instead of showing the User Message, it does not execute any line of code. Instead it shows.

Internet Explorer cannot display the webpage

But if I try uploading files between 1MB+ and -4MB, it shows the user message correctly. Cant seem to figure out what the problem could be. Any hints?

Below is my code

Dim path As String = Server.MapPath("~/UploadedFiles/")

Dim fileOK As Boolean = False

If FileUpload1.HasFile Then

If FileUpload1.PostedFile.ContentLength > 1048576 Then


Label2.Text = "File size should not be larger than 1 MB"


Dim fileExtension As String

fileExtension = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower()

Dim allowedExtensions As String() = {".jpg", ".jpeg", ".png", ".gif", ".pdf"}

For i As Integer = 0 To allowedExtensions.Length - 1

If fileExtension = allowedExtensions(i) Then

fileOK = True

End If


If fileOK Then


FileUpload1.PostedFile.SaveAs(path & _


Label1.Text = "File uploaded!"

Catch ex As Exception

Label1.Text = "File could not be uploaded."

End Try


Label1.Text = "Cannot accept files of this type."

End If

End If

End If


5/6/2008 12:20:24 PM 91979 articles. 4 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 7
Get it on Google Play
Get it on Apple App Store

By Default the File upload control can not upload file greater than 4 MB.
You have to modify your web.config for this..

<httpRuntime executionTimeout="1000" maxRequestLength="1048576"/>

The maxRequestLength property dictates the size of the request made to the Web server.When you upload files, the file is included in the request.

This example changes the maxRequestLength property's value to 1048576KB (around 1GB). With this setting in place, end users can upload 1Gb file to the server.

Look at this link

Virendra (MCTS)

My SiteBlog
5/6/2008 12:38:37 PM

Similar Artilces:

to file:// or not to file://
(Firefox I'm having trouble with HTML Anchors (links) using the file: protocol. The URL I'm trying to get at looks something like this file://///Host.Domain/Share/Dir1/Dir2/File.Ext If I click on the link, /nothing/ happens but, if I "Copy Link Location" and paste exactly the same thing into the "address bar" in FireFox, FireFox is perfectly happy to show me the file. Why the difference? Am I tripping over some security restriction here? Any suggestions? TIA, Phill W. Phill W. wrote: > (Firefox > I'm ...

How to get the load address of the .net executable file(exe file) ?
hello: I am reading an article about .net(Rewrite MSIL Code on the Fly with the .NET Framework Profiling API)from msdn, ,but i have some trouble about it . it said : If you added the method's RVA to the load address (the address where the executable file for the "Hello World!" assembly was loaded), you would see a memory dump layout similar to the one shown in Figure 3. On my machine, the load address was 0x06EA1000, I want to know : how can i get the load address of the exe file on my machine?is there s...

FTP: Delete File, Move File, Get File Properties (?)
Hi! Using the inet object, how can I (a) Delete an object from the FTP server (b) Move a file from one folder to another on the FTP server (c) Get file properties on a given file (e.g. datetime and size) Thanks! D I think I figured it out..... "Daniel Coppersmith" <> wrote in message > Hi! > > Using the inet object, how can I > (a) Delete an object from the FTP server > (b) Move a file from one folder to another on the FTP server > ...

Error in different perl scipt file
Dear Friends, I am beginner & i am new in perl scripting language, currently i using perl 5.8.8 version. I installed DBI module through CPAN to connect different database. Yes i got output by connecting to the database. My problem is : My first perl script filename is : My second perl script filename is : * When i run my first perl script file ( ) it running and i got the output. * But when i used to run my second perl script file ( ) its not running & i didn't get the output. Its showing "In...

Get File Version from EXE File
hi folks how can i get the file version from a exe file. i need that information for a setup download website. best regards Philipp Use System.Diagnostics.FileVersionInfo.GetVersionInfo(path) to get the version info of a file.Hope this helps!Paul yes, thanks a lot :)...

get file size from web file
Hello, I'm writing a application that is getting files from the internet. How can I get the filesize from a file (could also be an html or aspx page) that is located on the web? The only works for diskfiles. Kindest regards, Tom Govaert Hello, I passed through this before, you need to tranform the url into a physical address. Ask you hosting company on the disk drive that is used to access your files locally and then use it to do the conversion. regards.Bilal Hadiar, MCP, MCTS, MCPD, MCTMicrosoft MVP - Telerik MVP...

How to get file and open the file on screen?
Hi all, I am writing a tree view page in ( code behind), the tree will create folders and populate file names in the folder. Then I have to create a getfiles.aspx so that user can click on the file name and open the html file on screen in a separate page. In the main tree view page, I have a code to retrieve appropriate file names in the folder: oTree.Add(ChildFolder, "a0_0_0", "Actual vs. Weekly", False)                    Dim sPath As String      &n...

Get file extension of file in fileupload?
Hello there, I wonder how I can find the file extension of the file in the .net fileupload control?I know I can find the whole name, plus extension with fileupload.filename, is it then possible to find what there is after the last dot, or how can it be done? - Hope for help..----------------Regards,Jeppe Richardt I guess you dont have any built in method or property, you need to write code as in Example Dim strFileExtn As String = LCase(Right(file.FileName, 3))Vishal if you are wanting to limit what file a user can upload then use a regular expression validator, with an expre...

there are source files but no project file or solution file
I am working on a project, which only provides some .vb, .aspx, and other files. But there is no solution file or project file. How can I instal them in the development environment under .net visual studio 2005?   Thanks   David 1. Open Web Site from VS.NET 2005 to open this folder; 2. File -> Save All after you open the folder. VS.NET will pop up a window to let you save the project. Usually, after you save it, a .sln file will be saved to folder \Visual Studio 2005\Projects\YOURFOLDERNAME\ i f you don't change the folder for saving. Hope it helps."Objec...

Ho to split an Image (.tiff / .bmp file ) of 5 MB size
Hi Friends, I have .tiff image files. These can be .bmp files as well. I have to check for each image if my Image File Size is greater than 5 MB then I have to split my Image file into 5 files of 1 MB Each. Actually due to some file size restrictions while sending Attachment in Email, I have to check for each attachment size and have to split it into 1 MB each and then I have to send it one by one. Can you tell me how can I achieve this ? Thanks in Advance, Nirav      Why don't you convert them to the JPG format?Robert Kafarski,Aure Entuluva!- Day shall come aga...

how to make an VB.Net file into an Exe file?
Hi Friends, I am learning by myself. So if someone could help me out that wil be greatful. 1. How to make an file into an Exe file? 2. I hv to make a exit button which has to work as follows.... It has to display a msgbox "Do u want to quit?" and it needs Yes or No button... if u click, Yes the form has to close or stay as it is... I have written the code like this....But its not working.... Private sub btnExit_Click(Byval sender as object, ByVal e as EventArgs) Dim response as Msgboxresult msgbox("Do u want to quit?", Ms...

downloading files, get errors, as file could not be saved.
Name: Egon Mainey Email: Product: Deer Park Summary: downloading files, get errors, as file could not be saved. Comments: I've tried to download a few files from nvidia and, both times I get the following C:/docume~1\admin~1\locals~1\temp\oivoh98f.exe could not be saved, because the source file could not be read. I don't know weather it is a problem with XP64 or deerpark. I've had to resort to IE to get the files, which worked fine. If I've mad a mistake let me know or point me in the direction of the work around, you got m...

Cannot open a database file or file gets corrupted
We're running nsbs 6.5sp3 and client 4.91sp1. Sometimes in our custom made database program, we get an error message that a particular file cannot be opened. Closing and then reopening the program corrects the problem. The program exe and dll files reside in the workstation while the database files are in the server sys drive. Two questions. 1. TID10095627 says to enable level 2 oplocks if a server side database application is in use. If the database files are on the server but the executables are on the workstation, should we enable the oplocks? Currently this opti...

Get data from a text file to an HTML file
I am trying to read data from a text file ( has a username and usercode columns) to display on an html page. It there a way to do that? The text file changes information daily. I guess it would be better to have an xml file in place of the text file, then you would apply XSLT to the XML and display them on the page as html. Regards  Bilal Hadiar, MCP, MCTS, MCPD, MCTMicrosoft MVP - Telerik MVP The text file is generated from another program so I can't change the type of file.   Look at the System.IO namespace. Thare are readers in there where you pass in th...

Get file name of default file with HttpWebRequest
I'm using HttpWebRequest and HttpWebResponse to request a page off of another site. Is there a way to get the file name of the file I'm requesting when the request is pointing to a directory? For example the URL I'm requesting might be "" and the default file for that directory might be "myfile.aspx". How do I get the file's name "myfile"? I know that if you watch the host headers, you'll get back a 302 response with the default file's filename in it. I don't know if the WebRequest just handles this internally or if it migh...

Web resources about - File Upload - Uploading files greater than 4 MB -

Wikipedia:Uploading images - Wikipedia, the free encyclopedia
For more information on multimedia on Wikipedia in general (images, sound files, etc.), see Wikipedia:Media . Unfortunately large numbers of ...

Dropify Download 2.0 Simplifies Uploading Content To Facebook, Downloading, Sharing
... January, integrating with Facebook’s Open Graph and allowing users to make files available for download via the social network, and share uploading ...

New “Facebook for Every Phone” App Brings Photo Uploading and More to 2500 Different Feature Phones
Today, Facebook officially launched “Facebook for Every Phone”, a downloadable native mobile app compatible with 2500 different feature phones. ...

Defence bureaucrat pleads guilty to uploading secret document online
... embarrassing security breach with &quot;Five Eyes&quot; intelligence document. A former junior Defence bureaucrat has pleaded guilty to uploading ...

Uploading Bautista bat flip GIFs could get you sued under TPP, copyright activists warn
Copyright activists say Canadians could face lawsuits, fines or worse for ripping the latest Justin Bieber CD or uploading an animated GIF of ...

Facebook pages sharing less YouTube videos, uploading more video direct to site
While YouTube remains the gold standard for uploading videos online, a new study finds that its presence on Facebook is increasingly declining ...

Facebook for iOS updated with faster newsfeed, re-built timeline on iPhone, improved photo uploading
Facebook has updated its iOS application with improved speed for your timeline, newsfeed, and photo uploading. This update comes a couple of ...

Facebook Adds Features to Photo Uploading via iPhone, Android Apps
Facebook announced improvements to the ways that users upload photos to the social network via its iOS and Android flagship applications , allowing ...

Google Play Books updated, brings performance tweaks and uploading from your phone or tablet
PDF and ePub files can be shared to Google Play Books using the Android intents system

Twitter rolling out group messaging, 30-second video uploading
Fast Company Twitter rolling out group messaging, 30-second video uploading Android Community Different social networks are doing everything ...

Resources last updated: 11/22/2015 12:45:58 PM