This function will find the next available image name based on the $image given inside the $dir.
Quote
image_exists ( string $dir , string $image )
<?php
/* Content in IMAGES dir
image.jpg
image_1.jpg
image_2.jpg */
require_once INCLUDES."photo_functions_include.php";
$dir = IMAGES;
$image = "image.jpg";
echo image_exists($dir, $image);
?>
Quote
image_3.jpg