使用php / codeigniter删除文件 [英] Deleting a File using php/codeigniter
问题描述
我想删除在本地主机中找到的文件。
I would like to delete a file that is found in my localhost.
localhost/project/folder/file_to_delete
我正在为此使用codeigniter。
I'm using codeigniter for this.
我想在php中使用unlink()函数,但我真的不明白如何使用它。
I would like to use the unlink() function in php but I really can't understand how to use it.
推荐答案
您可以使用文件助手
CodeIgniter v3:
http://codeigniter.com/userguide3/helpers/file_helper.html#delete_files
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
CodeIgniter v4: http://codeigniter.com/user_guide/helpers/filesystem_helper.html#delete_files
之类
$this->load->helper("file");
delete_files($path);
后期修改: 删除文件
方法使用路径通过 unlink()
擦除所有内容,并且可以在CI中执行相同的操作。像这样:
Late delete_files
method uses a path to wipe out all of its contents via unlink()
and same you can do within CI. Like this:
unlink($path);
有效路径。
这篇关于使用php / codeigniter删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!