CodeIgniter Forums

Full Version: Get files from folder
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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

$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;
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 "/"