以下是我的代碼片段:如何檢查文件是否存在於目錄中或不在PHP中?
<?php
$filename = $test_data['test_name'].".pdf";
//I want to check whether the above file with the same extension(.pdf) is existing in the directory having name say "ABC" is present or not
?>
如果這樣的文件沒有在目錄「ABC」出現在那裏,那麼它應該創建相同的。 如果文件出現在「ABC」目錄中,則應該刪除它。 我嘗試了file_exists()
,但無法理解如何將其用於特定目錄。 任何人都可以在這方面指導我嗎?任何形式的幫助將不勝感激。
這個** ABC **目錄在哪裏?它是在包含PDF文件的目錄中還是在它之外?你能否在問題中包含一個目錄樹? – Subin
in'file_exists()'你可能必須傳遞完整路徑而不僅僅是文件名。 – Theraot