Deleting a File using php/codeigniter

前端 未结 9 1968
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-04 07:47

I would like to delete a file that is found in my localhost.

localhost/project/folder/file_to_delete

I\'m using codeigniter for this.

9条回答
  •  太阳男子
    2021-01-04 08:14

    simply can use:

    $file = "uploads/my_test_file.txt";
    
    if (is_readable($file) && unlink($file)) {
        echo "The file has been deleted";
    } else {
        echo "The file was not found";
    }
    

提交回复
热议问题