$i =1; while ($file = readdir($opendir)) { //exclude anything that doen't look like files. if($file != '..' && $file !='.' && $file !=''){ //dont't read direcories insde our directory. if (!is_dir($file)){ $filename1 = "./images/big/$file"; if (file_exists($filename1)) { // since i am using gallery we have to get the width and hieght of photos. $imgsize = getimagesize ($path_big."/".$file); // lets get the file size in byte/kb/mb. $file_size = filesize($path_big."/".$file); if ($file_size >= 1048576){ $show_filesize = number_format(($file_size / 1048576),2) . " MB"; }elseif ($file_size >= 1024){ $show_filesize = number_format(($file_size / 1024),2) . " KB"; }elseif ($file_size >= 0){ $show_filesize = $file_size . " bytes"; }else{ $show_filesize = "0 bytes"; } $filearray[] = $file; }else{ echo "Cannot find: $file "; } } } }//end while loop //define a variable to hold everthing that will be printed in table's columns. $all_stuff = "File name: $file