Not sure if this should be in code critique or general, but since I am looking for "what is the best" - then that is why it's in code critique...........mods feel free to move.
I am (very slowly) in the process of putting together my own gallery for my photographs & producing my own online blog. (why bother you might ask - when there is so many open source stuff anyway? I ask myself that all the time....)
anyway.
The way it works, I upload photographs using an iframe. I can repeatedly upload photograph after photograph. It resizes them as necessary, and stores a thumb in one dir and the max sized image in another. Before any of the images are available in the gallery, I must go to a form to add a photo to the gallery, and from here, I can click on an input field, and this opens up a window with the following php code.
<?php
$dir_handle = @opendir(THUMB_DIR) or die("Unable to open $path");
echo "Directory Listing of THUMB_DIR <br/>";
$count = 0 ;
$jpgArray = array () ;
//running the while loop
while ($file = readdir($dir_handle))
{
if($file!="." && $file!="..")
{
if(strstr($file, '.jpg')) {
$jpgArray[$count] = $file ;
$count = $count + 1 ;
}
}
}
rsort($jpgArray) ;
foreach ($jpgArray as $key => $image) {
?><img src="images/thumbs/<?php echo $image ; ?>" onclick="opener.Test('<?php echo $image ; ?>')" /><br />
<?php echo $image ; ?> <br /> <?php
}
?>
from this, I simply click on the image I want to associate with the form I have completed, and it returns the filename to the input field, and, displays a thumbnail on the form page (showing the correct image will be associated with the contents of the form)
My question is, is this better than having a table of filenames for each image?
The gallery would probably only have a maximum of 1000 images.
When there are 1000 images in the dir, then obviously the readdir() would take time to run, but would this be excessive? or would adding the filenames to a MySQL table be preferable and faster?
regards