function atleastOneFolderWritable($dir)
{
    global $writable_folders_found;
    $ffs = scandir($dir);
    foreach ($ffs as $ff) {
        if ($ff != '.' && $ff != '..' && is_dir($dir . '/' . $ff)) {
            if (tep_is_writable($dir . '/' . $ff)) {
                $writable_folders_found = true;
                break;
            }
            atleastOneFolderWritable($dir . '/' . $ff);
        }
    }
    return $writable_folders_found;
}
                <legend><?php 
echo AAS_PRODUCT_IMAGES_CURRENT_SMALL_IMAGE;
?>
<span id="product_images-current_image_path"></span></legend>
                  <div class="small_image_wrapper">
                    <img src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D" id="product_images-current-img" alt="product current image" width="<?php 
echo SMALL_IMAGE_WIDTH;
?>
" height="<?php 
echo SMALL_IMAGE_HEIGHT;
?>
">
                  </div>
              </fieldset>
<?php 
if (atleastOneFolderWritable(realpath(DIR_FS_CATALOG_IMAGES))) {
    ?>
              <fieldset id="dropbox-image">
                <legend><?php 
    echo AAS_PRODUCT_IMAGES_NEW_SMALL_IMAGE;
    ?>
</legend>
                <h2><?php 
    echo AAS_PRODUCT_IMAGES_DRAG_N_DROP_NEW_IMAGE_HERE;
    ?>
</h2><?php 
    echo AAS_PRODUCT_IMAGES_DRAG_N_DROP_NEW_IMAGE_HERE_OR;
    ?>
&nbsp;&nbsp;<input type="file" accept="image/*" name="products_image" id="products_image_change_default">
                  <fieldset class="dropbox-image-fieldset"><legend><?php 
    echo AAS_PRODUCT_IMAGES_SELECT_FOLDER_TO_SAVE_NEW_IMAGE;