国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 靖远县| 贵州省| 沙田区| 五常市| 小金县| 台湾省| 鄂州市| 县级市| 梓潼县| 尉犁县| 洛阳市| 卢龙县| 宜兴市| 屏边| 虞城县| 肥东县| 恩施市| 南通市| 大宁县| 徐水县| 灵台县| 怀集县| 金华市| 明水县| 玛沁县| 巨野县| 社会| 宜都市| 任丘市| 苍梧县| 台中县| 西贡区| 太白县| 华池县| 白河县| 商水县| 喀喇| 长乐市| 岑溪市| 南宁市| 子长县|