Im uploading documentsto list item in list by using file upload control. Now I should download that file. I can able to insert documents into list item in attachment column which is predefined but am how can I download the attachments by clicking on the link in display.aspx.
I have written this for uploadFile controller.
SPSite site = SPContext.Current.Site; SPWeb web = site.OpenWeb(); SPList list = web.Lists["list2"]; //SPListItem itemId = list.GetItemById(5); int itemId=3; SPListItem newItem = list.GetItemById(itemId); byte[] contents = null; if (FileUpload1.PostedFile != null && FileUpload1.HasFile) { using (Stream fileStream = FileUpload1.PostedFile.InputStream) { contents = new byte[fileStream.Length]; fileStream.Read(contents, 0, (int)fileStream.Length); fileStream.Close(); } SPAttachmentCollection attachments = newItem.Attachments; string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName); attachments.Add(fileName, contents); newItem["CLMSAttachments"] = fileName; newItem.Update(); }Thanks in advance.