IE 11 Download file Chinese garbled solve go/php

Source: Internet
Author: User
IE 11 downloaded the file when found garbled.

Online Check the information, understand, mainly user-agent changed, is no longer msie, face is rv:11.0 so, as long as the service side to determine that is IE 11, processing with the same as MSIE.

GO:

Funcsetdownloadfilename(whttp. Responsewriter,fileName,agentstring)  {
    Ifstrings. Contains(agent,"MSIE"){
        FileName=url. Queryescape(fileName)
        FileName=strings. Replace(fileName,"+","%20" ,  -1)
    }
    Ifstrings. Contains(agent,"rv:")&&  strings. Contains(agent,"Gecko"){
        FileName=url. Queryescape(fileName)
        FileName=strings. Replace(fileName,"+","%20",   -1) 
    }
    W. Header(). Set("content-disposition","attachment;filename=\" "  +fileName+"\" ")
}

Php:

$ua = Isset ($_server ["http_user_agent"])? $_server ["Http_user_agent"]: ';  if (Preg_match ("/msie/", $ua)) {$file _name = Rawurlencode ($file _name);  Header (' content-disposition:attachment; filename= '. $file _name. '"' );} else if (Preg_match ("/firefox/", $ua)) {header (' content-disposition:attachment; filename*= ' utf8\ ' \ '. $fil E_name. '"' );} ElseIf (Stripos ($ua, ' rv: ') > 0 && stripos ($ua, ' Gecko ') > 0) {$file _name = Rawurlencode ($f Ile_name);  header (' content-disposition:attachment; filename= '. $file _name. '"' );} else {header (' content-disposition:attachment; filename= '. $file _name. '"' );}

The above describes the IE 11 download file Chinese garbled solution go/php, including the aspects of the content, I hope that the PHP tutorial interested friends helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.