opalelement Posted May 12, 2009 Share Posted May 12, 2009 For some reason, this script: $maps = array(); echo "1"; if ($handle = opendir('/home2/cisarel/public_html/maps/')) { echo "2"; while (false !== ($file = readdir($handle))) { echo "3"; if (is_file($file) && !in_array($file, array("error_log", "update.php"))) { echo "4"; $maps[] = "$file"; echo "5"; } } closedir($handle); echo "6"; } (ignore teh echos for numbers, those were for seeing where it went) won't catch my php files when run from a cron job, but will catch them when run in a browser. I tried !is_file as a test, and it returned ., .., _vti_cnf, and store (which is a directory) in teh browser, but all of those plus my two php scripts in a cron job. Does is_file not work in a cron job? Link to comment https://forums.phpfreaks.com/topic/157831-cron-job-is_file-not-catching-valid-files/ Share on other sites More sharing options...
opalelement Posted May 12, 2009 Author Share Posted May 12, 2009 I tried is_dir and it returned the . and .., and !is_dir returned the two files, /store/, and /_vti_cnf/ I guess I will just have to do manual checking to make sure it isn't one of those. Link to comment https://forums.phpfreaks.com/topic/157831-cron-job-is_file-not-catching-valid-files/#findComment-832449 Share on other sites More sharing options...
w3evolutions Posted May 12, 2009 Share Posted May 12, 2009 Try this: $dir = "/My/Dir/"; $maps = array(); if(is_dir($dir)) { if($handle = opendir($dir)) { while(($file = readdir($handle)) !== false) { if($file != ".." && $file != ".") { $maps[] = $file; } } closedir($handle); } } Link to comment https://forums.phpfreaks.com/topic/157831-cron-job-is_file-not-catching-valid-files/#findComment-832492 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.