我正在尝试删除服务器上的文件。下面是我使用的代码。
function ServerDel($file){
$file = realpath($file);
echo ($file);
$fh = fopen($file, 'w') or die("can't open file");
fclose($fh);
if(unlink($file))
echo"Delete the file successfully.";
else
echo "Failed to delete.";
}
但是当我运行代码后,该文件仍然存在并且变成了0KB。有人知道如何解决这个问题吗?
使用a
标记在fopen()
代替w
.罢工>
$fh = fopen($file, 'a') or die("can't open file");
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)