コード例 #1
0
ファイル: products.php プロジェクト: rashidyusmen/myproject
 public function gallery()
 {
     $product_image_collection = new ProductImageCollection($_GET['id']);
     $no_file = 0;
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $product_gallery = new ProductImageEntity();
         $product_gallery->setProductId($_GET['id']);
         if ($_FILES['image']['tmp_name'] != '') {
             $product_gallery->saveImage($_FILES['image']);
             $product_image_collection->save($product_gallery);
         } else {
             $no_file = 1;
         }
     }
     $gallery = $product_image_collection->get_all();
     $this->LoadView('cms/product_gallery', array('gallery' => $gallery, 'no_file' => $no_file));
 }
コード例 #2
0
<?php

require_once __DIR__ . '/../common/autoload_cms.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $entity = new ProductImage();
    $entity->setName($_POST['name'])->setProductId($_GET['product_id'])->setDateAdded(date('Y-m-d H:i:s'))->saveImage($_FILES['image']);
    $productImageCollection = new ProductImageCollection();
    $productImageCollection->save($entity);
    header('Location: product_image_list.php?product_id=' . $_GET['product_id']);
    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" class="form-control">
        </div>

        <div class="form-group">
            <label for="image">Image:</label>
            <input type="file" name="image" id="image" class="form-control">
        </div>

        <button type="submit" class="btn btn-default">Submit</button>
    </form>
</div>

<?php