Get files from folder - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Get files from folder (/showthread.php?tid=61791) |
Get files from folder - eladr - 05-18-2015 Hi, Im trying to get files from folder. This code is working great in my dev machine.the dir variable is actually c:\xampp\...\... but in the real server this is the path... How it can be fixed? thanks in advance <?php $dir = $_SERVER['DOCUMENT_ROOT']."\\cisites\\application\\myworld\\public\\images\\myworldgalleries\\"; echo $dir; ///$dir = home/phptalki/public_html\cisites\application\myworld\public\images\myworldgalleries\ if (is_dir($dir)){ if ($dh = opendir($dir)){ while (($file = readdir($dh)) !== false){ $filepath = $dir . DIRECTORY_SEPARATOR . $file; echo $filepath; } closedir($dh); } } } ?> RE: Get files from folder - eladr - 05-18-2015 I used this: $dir_current = dirname(__FILE__); //replace with logs directory and point to log.html file $dir = str_replace('controllers', 'public', $dir_current)."/images/myworldgalleries/poland/org/"; and now it's ok...$_SERVER['DOCUMENT_ROOT'] is coming without leading "/" |