Alimon Karim
Alimon Karim

Reputation: 4469

File exists always returning false

My image directory is \webroot\files\thumbs

I am trying to add file_exists condition. For that I tried bellow code

$file = WWW_ROOT .'files' . DS . 'thumbs' . DS .'_'.$password->collection_id.'jpg';

$file_exists = file_exists($file);

It's always returning zero.

If I echo $file it's giving me output like this

c:\xampp\htdocs\myproject\files\thumbs\_61.jpg

Upvotes: 1

Views: 183

Answers (1)

BenM
BenM

Reputation: 53246

You're missing the . before the extension. Update your $file definition as follows:

$file = WWW_ROOT .'files' . DS . 'thumbs' . DS .'_'.$password->collection_id.'.jpg';
                                                       // This was missing ---^

$file_exists = file_exists($file);

Upvotes: 3

Related Questions