I am trying to use file exists in a subdirectory and running into some problems with the directory structure or perhaps something else. This code was working earlier when called from the main directory
The file that includes the command is in a subdirectory that is one directory below the main directory of the domain.
When I call the following on a file that I know exists nothing is returned, neither FALSE nor TRUE
$imgpath1 = 'pics/'.$userid.'_pic.jpg';
$exists = file_exists($imgpath1);
echo "1".$exists;//returns 1
I have tried different variations of the directory such as '/pics...' and also '../pics...' as well as the whole url begininning with 'http://www....' but cannot get it to return either a FALSE or a TRUE.
Would appreciate any suggestions.
var_dump($exists);.echo falseprints out nothing.echo truewould print out1, so you must be getting boolean false, meaning that directory doesn't exist. You need to know exactly where it is relative to this script's working directory, or provide an absolute path to it.