在chrome上怎么实现文件的下载?我用window.open(url),<a href="url"></a>,都不能实现下载,都是打开,怎么办?求救!!!chrome下载

解决方案 »

  1.   

    文件什么格式的?在IIS 上配置下 MIME 类型 应该就可以了。
      

  2.   

    音频,视频,图片,flash,要配置IIS? 那用户的机子上没有配置怎么办?
      

  3.   


     public void downloadfile(string s_fileName)
        {
            HttpContext.Current.Response.ContentType = "application/ms-download";
            string s_path = HttpContext.Current.Server.MapPath("~/") + s_fileName;
            System.IO.FileInfo file = new System.IO.FileInfo(s_path);
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.AddHeader("Content-Type", "application/octet-stream");
            HttpContext.Current.Response.Charset = "utf-8";
            HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(file.Name, System.Text.Encoding.UTF8));
            HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString());
            HttpContext.Current.Response.WriteFile(file.FullName);
            HttpContext.Current.Response.Flush();
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.End();
        }
      

  4.   


    对的 每一种类型(例如:*.mv,*.rmvb,*.wv) 都要配置 MIME 类型IIS 配置了 就好下载了,客户不用配置。参考
    http://blog.csdn.net/csethcrm/article/details/7018417里边没有的 可以百度搜一下