Increase File Upload Size Limit in Asp.net

Steps:

1) Create the simple web application.

2) On the Form put the below control.

2.1) File Upload Control (id: FileUpload1)

2.2) button control (id: btnUpLoad)

2.3) label control (id: lblError)

3) On the click event of the button (btnUpload) write following code.

‘check whether user selected any file or not

If FileUpload1.HasFile Then

Try

where you want to save this file –here is your drive information

FileUpload1.SaveAs(“C:\TestUpload\” & FileUpload1.FileName)

lblError.Text = “File Upload Successfully”

Catch ex As Exception

‘if any error occured at that time display message to user

lblError.Text = “ERROR: “ & ex.Message.ToString()

End Try

Else

‘if user is not selected any file at that time

lblError.Text = “Please Select The File”

End If

3) on above coding you upload file up to around 4 MB.

4) now change the setting in the web config file which are below.

4.1) <httpRuntime maxRequestLength=10000/>

By default maxRequestLength is 4096 kb. You can change that here.

thnx


http://amitpatriwala.blogspot.com/

Advertisements

One comment

  1. Haridharan · · Reply

    Hi, I have fixed my maxRequestLength as 51200 (50MB). while uploading more than 25MB will not work. “file or directory not found” error will occur. How to fix this issue?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s