PHP 提供了一些很棒的函数来管理服务器的硬盘。下面是如何使用它们。
复制()
从源文件复制文件。
$result = copy('original.txt','new.txt');
disk_free_space()
返回磁盘上剩余的字节数。
$free_space = disk_free_space('/');
disk_total_space()
以字节为单位返回磁盘大小。
$total_space = disk_total_space('/');
文件存在()
确认文件是否存在。
$exists = file_exists('rubbish.php');
取消链接()
从磁盘中删除一个文件。
$file = 'rub.txt'; if(file_exists($file)) { unlink($file); }
有关文件特定函数的更多信息,请阅读基本 PHP 文件处理 — 创建、打开、读取、写入、追加、关闭和删除。