Welcome Guest, Not a member yet? Register   Sign In
Get files from folder
#1

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);
}
}
}
?>
Reply
#2

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 "/"
Reply




Theme © iAndrew 2016 - Forum software by © MyBB