How to use Unlink() function

前端 未结 5 1019
说谎
说谎 2021-01-01 22:46

I\'m trying to use PHP unlink() function to delete away the specific document in the folder. That particular folder has already been assigned to full rights to

5条回答
  •  暖寄归人
    2021-01-01 23:43

    define("BASE_URL", DIRECTORY_SEPARATOR . "book" . DIRECTORY_SEPARATOR);
    define("ROOT_PATH", $_SERVER['DOCUMENT_ROOT'] . BASE_URL);
    
    $path = "doc/stuffs/sample.docx";
    
    if (unlink(ROOT_PATH . $Path)) {   
      echo "success";
    } else {
      echo "fail";    
    }
    
    // http://localhost/book/doc/stuffs/sample.docx
    // C:/xampp/htdocs\book\doc/stuffs/sample.docx
    

提交回复
热议问题