joda
08-22-2009, 12:16 AM
Can somebody explain why this code didn't work for me?
<?php
$path = "./images/";
$dir_handle = @opendir($path) or die("Unable to open folder");
while (false !== ($file = readdir($dir_handle))) {
if($file == "index.php")
continue;
if($file == ".")
continue;
if($file == "..")
continue;
echo "<img src='$file' alt='$file'><br />";
}
closedir($dir_handle);
So,the problem is:
If I change the value of $path = "./"; instead of $path = "./images/"; it is working,but if I change it from $path = "./"; to $path = "./images/"; i got all the time this message:
"Unable to open folder"
Pls. can somebody explain me the right way to make path changing in PHP and how can I change my path from "images" to "thums" or backward?
Thnx a lot.
<?php
$path = "./images/";
$dir_handle = @opendir($path) or die("Unable to open folder");
while (false !== ($file = readdir($dir_handle))) {
if($file == "index.php")
continue;
if($file == ".")
continue;
if($file == "..")
continue;
echo "<img src='$file' alt='$file'><br />";
}
closedir($dir_handle);
So,the problem is:
If I change the value of $path = "./"; instead of $path = "./images/"; it is working,but if I change it from $path = "./"; to $path = "./images/"; i got all the time this message:
"Unable to open folder"
Pls. can somebody explain me the right way to make path changing in PHP and how can I change my path from "images" to "thums" or backward?
Thnx a lot.