0
if(file_exists("/img/korica/Design_1.*"))
    echo "file exist";
else
    echo "there are no files with that name"
Nigel Ren
  • 56,122
  • 11
  • 43
  • 55
  • 1
    [this](https://stackoverflow.com/questions/2746364/php-file-exists-and-wildcard) might help – jibsteroos Dec 24 '19 at 08:56
  • Does this answer your question? [PHP: How to check if image file exists?](https://stackoverflow.com/questions/7991425/php-how-to-check-if-image-file-exists) – Link182 Dec 24 '19 at 08:59

2 Answers2

0

You can use scandir();

$files = scandir("/path/to/directory");
print_r($files);

another example:

<?php

$files = array_filter(scandir('/path/to/directory'), function($item) {
    return $item !== '.' && $item !== '..';
});

foreach ($files as $filename)
{
    if(file_exists("path/to/directory/$filename"))
    {
        echo "file exist\n";
    }
    else
    {
        echo "file doesn't exist\n";
    }
}
Simone Rossaini
  • 8,115
  • 1
  • 13
  • 34
0

You just need to use :glob() :

$existence= glob("./Yourdir/filename.*");

And then check if $existence has something or not!

It can also be used with a bash-like brace expansion:

glob("./uploads/filename.{jpg,jpeg,png,gif}", GLOB_BRACE).
Akif Hussain
  • 475
  • 5
  • 22