我想删除在我的本地主机中找到的文件。
localhost/project/folder/file_to_delete
我为此使用了 codeigniter。
我想在 php 中使用 unlink() 函数,但我真的不明白如何使用它。
最佳答案
您可以使用 codeigniter 中的“文件助手”。
CodeIgniter v3: http://codeigniter.com/userguide3/helpers/file_helper.html#delete_files
CodeIgniter v4:http://codeigniter.com/user_guide/helpers/filesystem_helper.html#delete_files
像这样:
$this->load->helper("file");
delete_files($path);
后期编辑: delete_files
方法使用路径通过 unlink()
删除其所有内容,您可以在 CI 中执行相同的操作。像这样:
unlink($path);
有效路径。
关于php - 使用 php/codeigniter 删除文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9747897/