工作笔记——多文件上传
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了工作笔记——多文件上传相关的知识,希望对你有一定的参考价值。
1 /// <summary> 2 /// 上传文件并显示出文件列表 3 /// </summary> 4 /// <param name="sender"></param> 5 /// <param name="e"></param> 6 protected void ImageButton2_Click(object sender, ImageClickEventArgs e) 7 { 8 // string FileNameStr = MYCLASS.PublicMethod.UploadFileIntoDir(this.FileUpload1, DateTime.Now.Ticks.ToString() + System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName)); 9 if (FileUpload1.FileName != "") 10 { 11 string FileNameStr = DateTime.Now.ToString("yyyymmddhhmmss") + FileUpload1.FileName; 12 if (MYCLASS.PublicMethod.GetSessionValue("WenJianList").Trim() == "") 13 { 14 MYCLASS.PublicMethod.SetSessionValue("WenJianList", FileNameStr); 15 } 16 else 17 { 18 MYCLASS.PublicMethod.SetSessionValue("WenJianList", MYCLASS.PublicMethod.GetSessionValue("WenJianList") + "|" + FileNameStr); 19 } 20 if (FileUpload1.FileName != "") 21 { 22 FileUpload1.SaveAs(Server.MapPath("~/gongshi/" + FileNameStr)); 23 } 24 MYCLASS.PublicMethod.BindDDL(this.CheckBoxList1, MYCLASS.PublicMethod.GetSessionValue("WenJianList")); 25 // this.Label2.Text = MYCLASS.PublicMethod.GetWenJian(MYCLASS.PublicMethod.GetSessionValue("WenJianList"), "../gongshi/"); 26 } 27 } 28 /// <summary> 29 /// 删除已选择的附件 30 /// </summary> 31 /// <param name="sender"></param> 32 /// <param name="e"></param> 33 protected void ImageButton3_Click(object sender, ImageClickEventArgs e) 34 { 35 try 36 { 37 for (int i = 0; i < this.CheckBoxList1.Items.Count; i++) 38 { 39 if (this.CheckBoxList1.Items[i].Selected == true) 40 { 41 MYCLASS.PublicMethod.SetSessionValue("WenJianList", MYCLASS.PublicMethod.GetSessionValue("WenJianList").Replace(this.CheckBoxList1.Items[i].Value, "").Replace("||", "|")); 42 } 43 } 44 MYCLASS.PublicMethod.BindDDL(this.CheckBoxList1, MYCLASS.PublicMethod.GetSessionValue("WenJianList")); 45 } 46 catch 47 { } 48 }
以上是关于工作笔记——多文件上传的主要内容,如果未能解决你的问题,请参考以下文章