Reputation: 462
I'm sure I'm missing something obvious here. I want to include a php file but I need to check if it exists first and every time I run it, I get a failure message. I can see the file is there from my FTP application.
<?
$man_file="/site/67/blog/612.php";
if (file_exists($man_file)){
include($man_file);
}
else
{
echo $man_file;
}
clearstatcache();
?>
Am I missing something?
Upvotes: 1
Views: 61
Reputation: 907
You need to put the path to the file as well. So try something like
$man_file=$_SERVER['DOCUMENT_ROOT']."/612.php";
If the directory you are searching is the root
.
Upvotes: 0
Reputation: 74232
That did it Fred. I've never had to do that before. Post it as an answer and I'll upvote it and accept it. – Richard Young
Posting my comment as "the" answer:
$man_file="/site/67/blog/612.php";
Use a full server path (an example):
$man_file="/var/usr/public/site/67/blog/612.php";
or a relative one.
Upvotes: 1