我用 php 创建了一个文件下载系统。我是这样创作的
phpfiledownload.php
--------------------
<?php
$file = 'testing.php';
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));
ob_clean();
flush();
readfile($file);
exit;
} ?>
我还创建testing.php
了如下文件
testing.php
------------
<?php echo "Hello World"; ?>
当我phpfiledownload.php
从本地主机运行时,我得到了testing.php
文件。
但是当我更改testing.php
为http://www.anotherdomain.com/example.php
in时,phpfiledownload.php
我无法下载http://www.anotherdomain.com/example.php
.
所以,我怎么http://www.anotherdomain.com/example.php
能通过我的 phpfiledownload.php