/// <summary> /// 上传文件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { //获得所需参数 string strTitle = tb_Title.Text.Trim(); HttpPostedFile hpf = file1.PostedFile; string strContent = tb_content.Text.Trim(); if (Convert.ToDouble(hpf.ContentLength) / 1024 / 1024 > 10) { Response.Write("<script>alert('附件大小不能大于10MB');</script>"); return; } else { CreateMdAndFilePaht(hpf); } //写入数据库 Tunnel.BLL.Tunnel_file rbll = new Tunnel.BLL.Tunnel_file(); Tunnel.Model.Tunnel_file model = new Tunnel.Model.Tunnel_file(); model.f_title = strTitle; model.f_size = hpf.ContentLength.ToString(); model.f_file = filePaht; model.f_addtime = DateTime.Now; model.f_Content = strContent; model.f_sort = 0; model.f_user = ul.LoginID; model.f_Ip = Tunnel.Common.Common.GetIp(); if (ul.GetUserBean(ul.LoginID) != null) { buMId = (int)ul.GetUserBean(ul.LoginID).m_id; } model.f_Bum = buMId; int relt1 = -1; relt1 = rbll.Add(model); string str = "上传文件"; string url = "FShaRing_Manage.aspx"; if (relt1 > 0) { str += "成功!"; } else { str += "失败!"; } MessageBox(str, url); }