Home  >  Article  >  Web Front-end  >  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
WBOYOriginal
2016-05-16 17:40:142051browse
复制代码 代码如下:

    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";  
Statement:
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