Пример #1
0
        if ($this->imgsGallery) {
            echo '<div class="gallery"><p class="title">' . $this->galleryName . '</p>';
            foreach ($this->imgsGallery as $tImg) {
                $imgUrlName = urlencode($tImg);
                echo "<div class='image_gallery'><a href='" . $this->dirName . $tImg . "'><img src=" . $this->dirName . $tImg . "></a><br><a class='action_url' href=" . $_SERVER['PHP_SELF'] . "?action=delete&delimg=" . $imgUrlName . ">Delete</a></div>";
            }
            echo '</div>';
        } else {
            $this->msg = 'There are no images in this folder. It\'s time upload your first image!';
        }
    }
}
$gallery = new ImageGallery('images/');
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if ($_FILES['userImage'] && !$_FILES['userImage']['error']) {
        $gallery->uploadImg('userImage');
    }
}
if ($_SERVER['REQUEST_METHOD'] === 'GET' && $_GET['action'] === 'delete') {
    $gallery->deleteImg(strip_tags($_GET['delimg']));
}
$gallery->prepareImages();
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        *{
            margin: 0;