php 下载保存文件保存到本地的两种实现方法
发布时间:2020-12-13 06:32:31 所属栏目:PHP教程 来源:网络整理
导读:第一种: 或 第二种: PHP实现下载文件的两种方法。分享下,有用到的朋友看看哦。 方法一: header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($filepath)); header('Content-Transfer-Enco
第一种: 或 第二种: PHP实现下载文件的两种方法。分享下,有用到的朋友看看哦。 方法一: header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($filepath)); 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($filepath)); readfile($file_path); ?> 了解php中header函数的用法。 方法二: (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |