In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how to achieve the php function that will not produce garbled code, I believe most people do not know much about it, so share this article for your reference. I hope you will gain a lot after reading this article. Let's go to know it together.
Sometimes we want to download content such as pictures, text documents, web pages, mp3, pdf and so on, when we click on the corresponding link, instead of displaying it on the web page, then we need to force the setting of header header information. The following is a piece of php function implementation code that will not generate garbled code, which can also be referenced by other programming languages.
/ * *
* Downloader
*
* @ param $archivo
* path al archivo
* @ param $downloadfilename
* (null | string) el nombre que queres usar para el archivo que se va a descargar.
* (si no lo especificas usa el nombre actual del archivo)
*
* @ return file stream
, /
Function download_file ($archivo, $downloadfilename = null) {
If (file_exists ($archivo)) {
$downloadfilename = $downloadfilename! = = null? $downloadfilename: basename ($archivo)
Header ('Content-Description: File Transfer')
Header ('Content-Type: application/octet-stream')
Header ('Content-Disposition: attachment; filename='. $downloadfilename)
Header ('Content-Transfer-Encoding: binary')
Header ('Expires: 0')
Header ('Cache-Control: must-revalidate, post-check=0, pre-check=0')
Header ('Pragma: public')
Header ('Content-Length:'. Filesize ($archivo))
Ob_clean ()
Flush ()
Readfile ($archivo)
Exit
}
}
The above is all the contents of this article, "how to achieve php functions that will not produce garbled codes". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.