<?php require_once __DIR__ . '/../common/autoload_cms.php'; $productImageCollection = new ProductImageCollection(); $image = $productImageCollection->one(array('id' => $_GET['id'])); if ($_SERVER['REQUEST_METHOD'] === 'POST') { $entity = new ProductImage(); $entity->setId($_GET['id'])->setProductId($image->getProductId())->setName($_POST['name'])->setDateAdded(date('Y-m-d H:i:s')); if ($_FILES['image']['error'] == UPLOAD_ERR_OK) { $entity->saveImage($_FILES['image']); } $productImageCollection = new ProductImageCollection(); $productImageCollection->save($entity); header('Location: product_image_list.php?product_id=' . $image->getProductId()); exit; } require_once 'include/header.php'; ?> <div class="container"> <form method="post" action="" enctype="multipart/form-data"> <div class="form-group"> <label for="name">Name:</label> <input type="text" name="name" id="name" value="<?php echo $image->getName(); ?> " class="form-control"> </div> <div class="form-group"> <label for="image">Image:</label>