Hello stiano,

Tuesday, December 30, 2003, 3:24:04 PM, you wrote:

son> Okay, I got my pathname straightened out, but I'm still showing the
son> "unexpected $" message.

The following works fine for me (on a Windows XP box + PHP4 + Apache)

<?
$dirName = "D:\Graphics";
if (is_dir($dirName) == TRUE)
{
        $dp = opendir($dirName);
        chdir($dirName);
}
else
{
        echo "Not a valid directory";
        exit;
}

//add all files in directory to $theFiles array
while ($currentFile !== FALSE)
{
        $currentFile = readDir($dp);
        $theFiles[] = $currentFile;
}

//extract gif and jpg images
$imageFiles = preg_grep("/jpg$|gif$/", $theFiles);

$output = "
<html>
        <head>
                <title>Image List</title>
        </head>
        
        <body>
        
        <p>
        Images in: $dirName
        </p>
";

foreach ($imageFiles as $currentFile)
{
        $output .= "<a href=\"$currentFile\"><img src=\"$currentFile\" height=50 
width=50></a>\n";
}

$output .= "
        </body>
</html>";

$fp = fopen("imageIndex.html", "w");
fputs ($fp, $output);
fclose($fp);
//      The following works, except that all the image links are broken because the 
directory is wrong
readFile("$dirName\imageIndex.html");
?>

-- 
Best regards,
 Richard                            mailto:[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to