I'm using a script to grab images from a directory and put them to the
screen, but i want it to ignore sub-directories like CVS/ . Adding the
tag "&& !is_dir($file)" to the correct conditional statement solved it
on my test server, but not on the actual site.
How is this possible? How can I fix it?
thanks,
RavenSlay3r
Working open-test site on Dreamhost.com servers (PHP 5.0 now i think)
Broken Mainsite running on BlueGravity.com servers (PHP 4 & 5)
http://lcpaver.com/index.php?colors_...s&paver_colors
Here's the script:
<?php
$image_dir = "images/colors/classic";
$dir_ptr = opendir("$image _dir/");
# grab images and put in an array
while ($file = readdir($dir_pt r)) {
$content[] = $file;
}
closedir($dir_p tr);
sort($content);
# output list of files found to page source for testing purpose
echo ("<!-- Files in " . $image_dir . " :\n");
foreach ($content as $file) {
echo ($file . "\n");
}
echo ("-->\n");
# Create new array with images only
$cnt=0;
foreach ($content as $image) {
if ( $image != "." && $image != ".." &&
!is_dir($image) ) {
# gets size of $image
$img_info = getimagesize("$ image_dir/$image");
// $img_info = $img_info[3];
$img_info = "style=\"width: 120px;
height:80px;\"" ;
$img_name = str_replace ("_", " ", $image);
$img_name = str_replace (".jpg", "",
$img_name);
# display $image
echo ("<div class=\"onecolo r\">");
echo ("<div class=\"imgshad ow\"
style=\"float: left;\">\n");
echo ("<img src=\"$image_di r/$image\"
alt=\"$img_name \"
$img_info>\n");
echo ("</div>\n");
echo ("<p>$img_na me</p>");
echo ("</div>\n");
$cnt++;
}
}
$maxItems = $cnt-1;
# output number of files found to page source for testing
purpose echo ("<!-- " . $maxItems . " images found -->\n");
if ($maxItems = 0) {
echo ("<h1>There are no images in this library</h1>");
}
?>
screen, but i want it to ignore sub-directories like CVS/ . Adding the
tag "&& !is_dir($file)" to the correct conditional statement solved it
on my test server, but not on the actual site.
How is this possible? How can I fix it?
thanks,
RavenSlay3r
Working open-test site on Dreamhost.com servers (PHP 5.0 now i think)
Broken Mainsite running on BlueGravity.com servers (PHP 4 & 5)
http://lcpaver.com/index.php?colors_...s&paver_colors
Here's the script:
<?php
$image_dir = "images/colors/classic";
$dir_ptr = opendir("$image _dir/");
# grab images and put in an array
while ($file = readdir($dir_pt r)) {
$content[] = $file;
}
closedir($dir_p tr);
sort($content);
# output list of files found to page source for testing purpose
echo ("<!-- Files in " . $image_dir . " :\n");
foreach ($content as $file) {
echo ($file . "\n");
}
echo ("-->\n");
# Create new array with images only
$cnt=0;
foreach ($content as $image) {
if ( $image != "." && $image != ".." &&
!is_dir($image) ) {
# gets size of $image
$img_info = getimagesize("$ image_dir/$image");
// $img_info = $img_info[3];
$img_info = "style=\"width: 120px;
height:80px;\"" ;
$img_name = str_replace ("_", " ", $image);
$img_name = str_replace (".jpg", "",
$img_name);
# display $image
echo ("<div class=\"onecolo r\">");
echo ("<div class=\"imgshad ow\"
style=\"float: left;\">\n");
echo ("<img src=\"$image_di r/$image\"
alt=\"$img_name \"
$img_info>\n");
echo ("</div>\n");
echo ("<p>$img_na me</p>");
echo ("</div>\n");
$cnt++;
}
}
$maxItems = $cnt-1;
# output number of files found to page source for testing
purpose echo ("<!-- " . $maxItems . " images found -->\n");
if ($maxItems = 0) {
echo ("<h1>There are no images in this library</h1>");
}
?>
Comment