0
if(file_exists("/img/korica/Design_1.*"))
    echo "file exist";
else
    echo "there are no files with that name"
2

2 Answers 2

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";
    }
}
Sign up to request clarification or add additional context in comments.

Comments

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).

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.