Richard Young Richard Young - 2 months ago 14
PHP Question

Checking existence of file in same folder

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?

Answer

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.