C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » ASP.NET »

Uploading large files System.OutOfMemoryException Occurs


Posted Date: 07 Nov 2009      Posted By: Muraleedharan.k      Member Level: Silver     Points: 1   Responses: 3



When i am uploading large files the error:System.OutOfMemoryException error occurs on file attaching and also occurs on saving that uploaded files.




Responses

Author: sri    07 Nov 2009Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

try this code for upload

private void StartUpLoad()
{
//get the file name of the posted image
string imgName = FileUpload1.FileName.ToString();
//sets the image path
string imgPath = "ImageStorage/" + imgName;
//then save it to the Folder
FileUpload1.SaveAs(Server.MapPath(imgPath));

//get the size in bytes that
int imgSize = FileUpload1.PostedFile.ContentLength;

//validates the posted file before saving
if (FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "")
{
if (FileUpload1.PostedFile.ContentLength >965120) // 5120 KB means 5MB
{
Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Alert", "alert('File is too big')", true);
}
else
{
//save the file
//Call the method to execute Insertion of data to the Database
ExecuteInsert(imgName, imgSize, imgPath);
Response.Write("Save Successfully!");
}
}
}

pls give me rate
Thanks & Regards
sri



Author: vipul    07 Nov 2009Member Level: DiamondRating: 3 out of 53 out of 53 out of 5     Points: 3

Hi,
for that you can changes one thing into web.config file

<httpRuntime
maxRequestLength="2097151"
/>


Please Rate This Answer If They Helpful

Thanks & Regards
Patel Vipul



Author: parthiban    07 Nov 2009Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

add this your web.config file and try to upload

<httpRuntime
executionTimeout="90"
maxRequestLength="4096"
useFullyQualifiedRedirectUrl="false"
minFreeThreads="8"
minLocalRequestFreeThreads="4"
appRequestQueueLimit="100"
enableVersionHeader="true"
/>

or

refer to this site

Refference

http://www.codeproject.com/KB/aspnet/uploadlargefilesaspnet.aspx#



Post Reply
You must Sign In to post a response.
Next : Conversion of files
Previous : I want telerik functionality without telerik control..
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use