我想通过Php在服务器中写入一个文本文件,并让客户端下载该文件。
我该怎么做?
本质上,客户端应该能够从服务器下载文件。
最佳答案
假设您不希望用户看到文件的真实 URL,这是最好的方法。
<?php
$filename="download.txt";
header("Content-disposition: attachment;filename=$filename");
readfile($filename);
?>
此外,您可以使用 mod_access 保护您的文件。
关于php - 发送文件给客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/737045/