Home > Web Front-end > JS Tutorial > Solutions to garbled file names in individual browsers when downloading files_javascript techniques

Solutions to garbled file names in individual browsers when downloading files_javascript techniques

WBOY
Release: 2016-05-16 17:40:14
Original
2096 people have browsed it
复制代码 代码如下:

    if (context.Request.UserAgent.ToLower().IndexOf("msie", System.StringComparison.Ordinal) > -1)//IE浏览器
 {
     context.Response.AddHeader("content-disposition", "filename=" HttpUtility.UrlEncode(fileName));
 }
 if (context.Request.UserAgent.ToLower().IndexOf("firefox", System.StringComparison.Ordinal) > -1)//firefox浏览器
 {
     context.Response.AddHeader("content-disposition", "attachment;filename="" fileName """);
 }
 else//其他浏览器
 {
     context.Response.AddHeader("content-disposition", "attachment;filename=" fileName);
 }
 context.Response.ContentType = "application/x-xls";  
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template