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

May 16, 2016 pm 05:40 PM
download

复制代码 代码如下:

    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 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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use magnet links How to use magnet links Feb 18, 2024 am 10:02 AM

How to use magnet links

How to download episodes of Hongguo short drama How to download episodes of Hongguo short drama Mar 11, 2024 pm 09:16 PM

How to download episodes of Hongguo short drama

What should I do if I download other people's wallpapers after logging into another account on wallpaperengine? What should I do if I download other people's wallpapers after logging into another account on wallpaperengine? Mar 19, 2024 pm 02:00 PM

What should I do if I download other people's wallpapers after logging into another account on wallpaperengine?

How to download links starting with 115://? Download method introduction How to download links starting with 115://? Download method introduction Mar 14, 2024 am 11:58 AM

How to download links starting with 115://? Download method introduction

How to download videos from a video account 'Must-see: A simple way to save videos from a video account' How to download videos from a video account 'Must-see: A simple way to save videos from a video account' Feb 06, 2024 pm 06:42 PM

How to download videos from a video account 'Must-see: A simple way to save videos from a video account'

How to download files from 123 cloud disk How to download files from 123 cloud disk Feb 23, 2024 pm 08:58 PM

How to download files from 123 cloud disk

How to download Baidu Netdisk files How to download Baidu Netdisk files Feb 23, 2024 pm 06:20 PM

How to download Baidu Netdisk files

How to download Quark network disk to local? How to save files downloaded from Quark Network Disk back to the local computer How to download Quark network disk to local? How to save files downloaded from Quark Network Disk back to the local computer Mar 13, 2024 pm 08:31 PM

How to download Quark network disk to local? How to save files downloaded from Quark Network Disk back to the local computer

See all articles