国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

文件下載功能

2019-11-17 01:26:13
字體:
來源:轉載
供稿:網(wǎng)友

文件下載功能

代碼如下:

/// <summary>/// 附件下載/// </summary>/// <param name="attachId">附件ID</param>public void DownloadAttach(int attachId){    Edu_Attach edu_Attach = edu_AttachService.findById<Edu_Attach>(attachId);    if (edu_Attach != null)    {        HttpContext context = (HttpContext)ctx.web.Context;        if (context != null)        {            string filePathName = PathHelper.Map(sys.Path.DiskPhoto) + edu_Attach.AttachContent.Replace("/static/upload/image", "").Replace("/", "http://");            int pos = filePathName.LastIndexOf("http://");            string fileName = filePathName.Substring(pos + 1);            string UserAgent = context.Request.ServerVariables["http_user_agent"].ToLower();            if (UserAgent.IndexOf("Firefox") == -1)            {                //非火狐瀏覽器                context.Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode(edu_Attach.AttachName));            }            else            {                context.Response.AddHeader("content-disposition", "attachment;filename=" + edu_Attach.AttachName);            }            FileStream fs = new FileStream(filePathName, FileMode.Open, Fileaccess.Read);            byte[] bArr = new byte[fs.Length];            fs.Read(bArr, 0, bArr.Length);            fs.Close();            context.Response.ContentEncoding = Encoding.UTF8;            context.Response.BinaryWrite(bArr);            context.Response.Flush();            context.Response.End();        }    }}
View Code


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 政和县| 松桃| 蒙山县| 南平市| 彭州市| 天水市| 甘南县| 乐清市| 边坝县| 保靖县| 胶南市| 新乐市| 江永县| 临潭县| 辽阳县| 原阳县| 神木县| 宝山区| 建湖县| 新郑市| 扎鲁特旗| 望奎县| 郑州市| 阳新县| 曲周县| 汽车| 祁连县| 通江县| 宜丰县| 满城县| 平顶山市| 阳曲县| 开封县| 马关县| 凤台县| 钦州市| 安化县| 连州市| 隆安县| 玉溪市| 襄汾县|