【发布时间】:2014-01-11 09:44:31
【问题描述】:
以下是我的代码 sn-p:
<?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 文件的目录中还是在它之外?您能否在问题中包含目录树?
-
在
file_exists()中,您可能必须传递完整路径,而不仅仅是文件名。
标签: php file pdf filenames file-exists