Home >Backend Development >PHP Tutorial > php下载服务器上的资料

php下载服务器上的资料

WBOY
WBOYOriginal
2016-06-13 12:38:28867browse

php下载服务器上的文件

   $file_xls=$path;    //   文件的保存路径

   $example_name=basename($file_xls);  //获取文件名


   header('Content-Description: File Transfer');
   header('Content-Type: application/octet-stream');
   header('Content-Disposition: attachment; filename='.mb_convert_encoding($example_name,"gb2312","utf-8"));  //转换文件名的编码
   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($file_xls));
   ob_clean();
   flush();
   readfile($file_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