// Variables and math for files within target directory
$num_files = 0;
$num_rows = 0;
$remainder = 0;
$i = 1; //three counters
$j = 1;
$k = 1;
// php.ini parameter register_globals should be OFF.
// Use superglobal _POST variable to access form data.
$alt_text = $_POST['alt_text'];
$current_path = $_POST['current_path'];
$current_text = $_POST['current_text'];
$final_directory = $_POST['final_directory'];
$final_path = $_POST['final_path'];
//////////////////////////////////////////////////////////////
// BEGINNING OF SECTION THAT CREATES A TABLE OF THUMBNAILS.
// THUMBNAILS ARE IN A DIRECTORY INSIDE OF MAIN PHOTOS
// DIRECTORY CALLED "thumbs"
//////////////////////////////////////////////////////////////
// Fill an array with all items from a directory.
if ($handle = opendir($current_path)) {
while (false !== ($file_name = readdir($handle))) {
$pic_array[] = $file_name;
//echo "$file_name
"; //debug
}
closedir($handle);
}
// Take only the jpgs into a sorted array.
$n=1;
//echo "
"; //debug:
foreach ($pic_array as $mypic){
$file_ext = strstr($mypic,'.');
if($file_ext == ".jpg" || $file_ext ==".JPG") {
$nice_array[$n] = $mypic;
//echo "nice_array $n is $nice_array[$n]
\n"; //debug
$n = $n+1;
}
}
// Get number of items in array and the remainder when divided by 3
$num_files = count($nice_array);
$num_rows = floor($num_files/3);
$remainder = $num_files%3;
// This is for debugging only.
// echo "\n
"; // echo "Number of files: $num_files\n"; // echo "\n
";
// foreach ($pic_array as $mypic){
// echo "$mypic
";
// }
// Create a table of thumbnails 3 columns wide
echo "