4
$filename = '/www/test1/*.pdf';
    if (file_exists($filename)) 
    {
        echo "The file $filename exists";
    } 
    else
    {
        echo "The file $filename does not exist";
    }

I used above code but it checks for *.pdf file but not for all files belongs to .pdf extension

fedorqui
  • 275,237
  • 103
  • 548
  • 598
M Gaidhane
  • 531
  • 8
  • 29
  • 2
    What result do you expect here? You want to test whether *any* file with a PDF extension exists in that directory? – deceze May 29 '13 at 12:49
  • Thanks for your support. yes, i was searching for any file available with a PDF extension in the directory and as per Mr.Mark Baker's post, i got the answer. – M Gaidhane May 30 '13 at 10:04

1 Answers1

11
$filename = '/www/test1/*.pdf';
if (count(glob($filename)) > 0) {
    echo "The file $filename exists";
} else {
    echo "The file $filename does not exist";
}
Mark Baker
  • 209,507
  • 32
  • 346
  • 385