I am trying to read a a .conf file under /var/www/myDir on linux.
This is the code
$confFile = "vhost.conf";
if (file_exists($confFile)) {
echo "The file $filename exists";
} else {
echo "Th开发者_高级运维e file $filename does not exist";
}
It says file not found. Any ideas why>
Thanks Jean
Give the full path
$confFile = "/var/www/myDir/vhost.conf";
is your script executed in the same Path? otherwise try using the full path
if (file_exists('/var/www/myDir'. $confFile)) {
...
Try using absolute paths, like this:
$confFile = $_SERVER['DOCUMENT_ROOT'] . "/vhost.conf"; if (file_exists($confFile)) { echo "The file $filename exists"; } else { echo "The file $filename does not exist"; }
Or maybe this:
$confFile = "/var/www/myDir/vhost.conf"; if (file_exists($confFile)) { echo "The file $filename exists"; } else { echo "The file $filename does not exist"; }
精彩评论