| Author: sri 07 Nov 2009 | Member Level: Silver | Rating:  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 2009 | Member Level: Diamond | Rating:   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 2009 | Member Level: Silver | Rating:  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#
|