Forum Moderators: coopster
<?
$NAMEFILE = "index.php"; //This files name.
$dir = opendir("./images"); //Replace the dot with ./yourfolder or leave it as it is.
while ($file = readdir($dir)) {
if ($file!= "." && $file!= ".." && $file!= "$NAMEFILE") {
$time = filemtime("$file");
$data[$time] = "<a href=\"$file\" target=\"new\"><img src=\"$file\" border=\"0\" bordercolor=\"black\" width=\"50\" height=\"50\"></a>
";
}}
krsort($data);
while(list($k,$v) = each($data)) { echo $v; }
clearstatcache();
echo "<br />";
?>
Warning: opendir(./images): failed to open dir: No such file or directory in /home/user/public_html/images/index.php on line 3Warning: readdir(): supplied argument is not a valid Directory resource in /home/user/public_html/images/index.php on line 4
Warning: krsort() expects parameter 1 to be array, null given in /home/user/public_html/images/index.php on line 11
Warning: Variable passed to each() is not an array or object in /home/user/public_html/images/index.php on line 12
I have a file called index.php and I place it on my server in the image directory.
It is supposed to display all the images in the directory.
<?
$NAMEFILE = "index.php"; //This files name.
$dir = opendir("./images"); //Replace the dot with ./yourfolder or leave it as it is.
while ($file = readdir($dir)) {
if ($file!= "." && $file!= ".." && $file!= "$NAMEFILE") {
$time = filemtime("$file");
$data[$time] = "<a href=\"$file\" target=\"new\"><img src=\"$file\" border=\"0\" bordercolor=\"black\" width=\"50\" height=\"50\"></a>
";
}}
krsort($data);
while(list($k,$v) = each($data)) { echo $v; }
clearstatcache();
echo "<br />";
?>
I get this error
Warning: opendir(./images): failed to open dir: No such file or directory in /home/user/public_html/images/index.php on line 3
Warning: readdir(): supplied argument is not a valid Directory resource in /home/user/public_html/images/index.php on line 4
Warning: krsort() expects parameter 1 to be array, null given in /home/user/public_html/images/index.php on line 11
Warning: Variable passed to each() is not an array or object in /home/user/public_html/images/index.php on line 12
I have a file called index.php and I place it on my server in the image directory.
It is supposed to display all the images in the directory.
<?
$NAMEFILE = "index.php"; //This files name.
$dir = opendir("./images"); //Replace the dot with ./yourfolder or leave it as it is.
while ($file = readdir($dir)) {
if ($file!= "." && $file!= ".." && $file!= "$NAMEFILE") {
$time = filemtime("$file");
$data[$time] = "<a href=\"$file\" target=\"new\"><img src=\"$file\" border=\"0\" bordercolor=\"black\" width=\"50\" height=\"50\"></a>
";
}}
krsort($data);
while(list($k,$v) = each($data)) { echo $v; }
clearstatcache();
echo "<br />";
?>
I get this error
Warning: opendir(./images): failed to open dir: No such file or directory in /home/user/public_html/images/index.php on line 3
Warning: readdir(): supplied argument is not a valid Directory resource in /home/user/public_html/images/index.php on line 4
Warning: krsort() expects parameter 1 to be array, null given in /home/user/public_html/images/index.php on line 11
Warning: Variable passed to each() is not an array or object in /home/user/public_html/images/index.php on line 12
What say ye?