下载文件

context.Response.ContentType = "text/plain";

    string filename = context.Request.QueryString["u"];

    string path = context.Request.MapPath("../images/"+filename);
    
    //解决ie中下载时候。中文文件名称乱码的问题
    filename = HttpUtility.UrlEncode(filename);
    
    context.Response.AddHeader("Content-Disposition", "attachment;filename="+filename);

    context.Response.WriteFile(path);

posted on 2015-02-19 10:28  木屐  阅读(85)  评论(0编辑  收藏  举报

导航