以下是我的代码片段:如何检查文件是否存在于目录中或不在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