Uploading Multiple Files....
-
Hi to All, Here i am trying to upload multiple files on a server. This works fine for the files having size less than 4 to 5 MB, but whenever i trying to upload the file whos size is more than that it even does not take that file. Here i am using a List box to contain the files to be uploaded. the code for "add files" and "upload files" as follows.... //code for Add file Button private void AddFile_Click(object sender, System.EventArgs e) { lblStatus.Visible=true; lblStatus.Text=""; //call to HideControl() HideControls(1); bool b=true; if (Page.IsPostBack == true) { listFileList.AutoPostBack=true; // This function adds the selected files in the List Box. // if the file is not selected then it dispalyes the error message. // Check for the availability of the files in the FindFile control. if (FindFile.Value!="") { if (listFileList.Items.Count!=0) { for (int i=0; i1) Upload.Text= "Upload All"; else Upload.Text= "Upload File"; listFileList.AutoPostBack=true; }// end of AddFile_Click() // Code for Upload file button private void Upload_Click(object sender, System.EventArgs e) { if (!IsPostBack==false) { HideControls(1); //string stat1=""; string baseLocation = Server.MapPath("~/Files/Upload/"); string status = ""; if((listFileList.Items.Count == 0) && (filesUploaded == 0)) { lblStatus.Text = "Error - a file name must be specified."; return; }// end of if // call to CheckUploadFile() to check availability of the details of specified file CheckUploadFile(); // if details of all files available then only it uploads these files if (stat == "") { HtmlInputFile HIF = new HtmlInputFile(); foreach(System.Web.UI.HtmlControls.HtmlInputFile HIF1 in hif) { string fn = ln + "-" + System.IO.Path.GetFileName(HIF1.PostedFile.FileName); if (File.Exists(baseLocation+fn)==false) { HIF1.PostedFile.SaveAs(baseLoc
-
Hi to All, Here i am trying to upload multiple files on a server. This works fine for the files having size less than 4 to 5 MB, but whenever i trying to upload the file whos size is more than that it even does not take that file. Here i am using a List box to contain the files to be uploaded. the code for "add files" and "upload files" as follows.... //code for Add file Button private void AddFile_Click(object sender, System.EventArgs e) { lblStatus.Visible=true; lblStatus.Text=""; //call to HideControl() HideControls(1); bool b=true; if (Page.IsPostBack == true) { listFileList.AutoPostBack=true; // This function adds the selected files in the List Box. // if the file is not selected then it dispalyes the error message. // Check for the availability of the files in the FindFile control. if (FindFile.Value!="") { if (listFileList.Items.Count!=0) { for (int i=0; i1) Upload.Text= "Upload All"; else Upload.Text= "Upload File"; listFileList.AutoPostBack=true; }// end of AddFile_Click() // Code for Upload file button private void Upload_Click(object sender, System.EventArgs e) { if (!IsPostBack==false) { HideControls(1); //string stat1=""; string baseLocation = Server.MapPath("~/Files/Upload/"); string status = ""; if((listFileList.Items.Count == 0) && (filesUploaded == 0)) { lblStatus.Text = "Error - a file name must be specified."; return; }// end of if // call to CheckUploadFile() to check availability of the details of specified file CheckUploadFile(); // if details of all files available then only it uploads these files if (stat == "") { HtmlInputFile HIF = new HtmlInputFile(); foreach(System.Web.UI.HtmlControls.HtmlInputFile HIF1 in hif) { string fn = ln + "-" + System.IO.Path.GetFileName(HIF1.PostedFile.FileName); if (File.Exists(baseLocation+fn)==false) { HIF1.PostedFile.SaveAs(baseLoc
PRB: Cannot Upload Large Files When You Use the HtmlInputFile Server Control
:
RESOLUTION To resolve this problem, use one of the following methods: • In the Machine.config file, change the maxRequestLength attribute of the configuration section to a larger value. This change affects the whole computer. • In the Web.config file, override the value of maxRequestLength for the application. For example, the following entry in Web.config allows files that are less than or equal to 8 megabytes (MB) to be uploaded:
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)