Deleting a File using php/codeigniter

前端 未结 9 1881
爱一瞬间的悲伤
爱一瞬间的悲伤 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:10

    http://php.net/manual/en/function.unlink.php

    It is the best way to understand. Read it!

    $path_to_file = '/project/folder/file_to_delete';
    if(unlink($path_to_file)) {
         echo 'deleted successfully';
    }
    else {
         echo 'errors occured;
    }
    

提交回复
热议问题