我在内容管理系统上工作,我必须使用PHP代码下载一个PHP文件而不执行.任何人都可以帮助我
它有点像ftp.我添加了上传,编辑和下载文件的选项.它工作正常.但在下载一个php文件时,它被执行而不是下载…
我尝试的是:
$file = $_REQUEST['file_name'];
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
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));
include_once($file);
exit;
}
?>