How to solve the problem of downloading attachments in PHP IE
This article mainly introduces "how to solve the problem of downloading attachments in PHP IE". In daily operation, I believe many people have doubts about how to solve the problem of downloading attachments in PHP IE. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts of "how to solve the problem of downloading attachments in PHP IE". Next, please follow the editor to study!
Key points:
1. Clear the cache before downloading attachments in IE.
2. The Chinese file name should be encoded with urlencode.
The copy code is as follows:
Header ("Pragma:"); / / if not added, the target host will be prompted in IE that it cannot be accessed.
Header ("Cache-Control:"); / / if not added, the target host will be prompted in IE that it cannot be accessed.
Header ("content-type: $type")
Header ("accept-ranges: bytes")
Header ("Content-Transfer-Encoding:base64")
Header ("accept-length:" Filesize ($path_c))
Header ("content-disposition: attachment; filename=" .urlencode ($filename)); / / garbled Chinese names without urlencode in IE
Readfile ($path_c)
Exit
Or
The copy code is as follows:
Header ('Content-Description: File Transfer')
Header ('Content-Type: application/octet-stream')
Header ('Content-Disposition: attachment; filename='.urlencode (basename ($file); / / garbled Chinese names without urlencode in IE
Header ('Content-Transfer-Encoding: binary'); / / binary transmission
Header ('Expires: 0')
Header ('Cache-Control: must-revalidate, post-check=0, pre-check=0'); / / if not added, the target host will be prompted in IE that the destination host cannot be accessed
Header ('Pragma: public'); / / if not added, the target host will be prompted in IE that the destination host cannot be accessed
Header ('Content-Length:'. Filesize ($file))
Ob_clean ()
Flush ()
Readfile ($file)
Exit
At this point, the study on "how to solve the problem of downloading attachments in PHP IE" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!