The Little Guy Posted June 30, 2008 Share Posted June 30, 2008 This may be more complicated than the following code, maybe not. First off, here is the basic code: if(file_exists('cat')) echo 'yes'; else echo 'no'; the above file (index.php) is in the exact same directory as "cat". dir layout: root | +-cat | +-index.php OK, with that being said, The file "index.php" is being run through another file "viewFile.php", using some .htaccess rules, if you go to http://test.hostbox.us/index.php you are actually are going to http://hostbox.us/subdomains/test/index.php where test is the root. the above file will work if you go to http://hostbox.us/subdomains/test/index.php it will say yes but if you go here: http://test.hostbox.us/index.php it will say no What I need is for both urls to say yes if(file_exists($readF)){ if(!$err && !$isO){ include($readF); // This includes the file that will be read in such as index.php }else{ readfile($readF); } } Link to comment https://forums.phpfreaks.com/topic/112610-file_exists-problem/ Share on other sites More sharing options...
DyslexicDog Posted June 30, 2008 Share Posted June 30, 2008 You need to use the whole string for the file location. i.e. /var/www/http/sitename/folder/file Link to comment https://forums.phpfreaks.com/topic/112610-file_exists-problem/#findComment-578378 Share on other sites More sharing options...
The Little Guy Posted June 30, 2008 Author Share Posted June 30, 2008 where would I use the whole string? here: file_exists('cat') OR here: include($readF); Link to comment https://forums.phpfreaks.com/topic/112610-file_exists-problem/#findComment-578390 Share on other sites More sharing options...
DyslexicDog Posted June 30, 2008 Share Posted June 30, 2008 In both places. <?php $workingdir = "/var/www/html/webspace"; if file_exists($workingdir.'/file.inc'){ ... ?> Link to comment https://forums.phpfreaks.com/topic/112610-file_exists-problem/#findComment-578570 Share on other sites More sharing options...
br0ken Posted June 30, 2008 Share Posted June 30, 2008 You could even use the function realpath() which returns the absolute path for the relative path provided. http://php.net/realpath Link to comment https://forums.phpfreaks.com/topic/112610-file_exists-problem/#findComment-578669 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.