<?php $image = new LastWorks(); if (isset($_POST['add_image'])) { if (isset($_FILES['fup_image'])) { $image->last_works_title = $_POST['last_works_title']; $image->last_works_status = $_POST['cb_visibility']; $image_tmp_name = $_FILES['fup_image']['tmp_name']; $image_name = $_FILES['fup_image']['name']; move_uploaded_file($image_tmp_name, "../img/" . $image_name); $image->last_works_image = $image_name; $image->insert(); echo "<div class='alert alert-success'> \n <i><strong>Image successfully uploaded. :)</strong></i>\n </div>"; } else { echo "<div class='alert alert-danger'> \n <i><strong>Incomplete data!!! Try again.</strong></i>\n </div>"; } } /*****************************************************************************/ ?> <h3>Add new image in Last Works</h3> <br> <br> <form action="" method="POST" enctype="multipart/form-data" > <label> Choose image </label> <input type="file" name="fup_image" required> </input> <br> <br>
<div class="canvas gallery"><br> <h1 class="blog-post-title text-center">Gallery of Images</h1> <span class="title-divider"></span> </section> <section id="photostack-3" class="photostack"> <div> <!-- one image --> <?php $all_images = LastWorks::getAll("WHERE last_works_status=1"); //print_r($all_images); //<a href='{$image->last_works_link}' target='blank'>Link</a> ako zatreba link kad shutterstock.com,prebaci u echo foreach ($all_images as $image) { echo "<figure>\n <a href='img/{$image->last_works_large}' data-lightbox='studio2' class='photostack-img'><img src='img/{$image->last_works_small}' alt='{$image->last_works_alt}'/></a>\n <figcaption>\n <h2 class='photostack-title'>{$image->last_works_title}</h2>\n <div class='photostack-back'>\n <br><br><br><br>\n <p><a href='http://www.shutterstock.com/g/ngaga35' target='blank'>Check my Shutterstock portfolio</a></p>\n <p><a href='http://www.shutterstock.com/g/ngaga35' target='blank'><img src='img/shutterstock.jpg'></a></p>\n </div>\n </figcaption>\n </figure>"; } ?> <!-- end of one image --> </div> </section> </div> <!-- Bootstrap core JavaScript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="js/classie.js"></script> <script src="js/photostack.js"></script>
<?php if (isset($_POST['edit_last_works'])) { $text_image = LastWorks::get($_POST['edit_last_works']); $_SESSION['change_text_last_works'] = $text_image; // print_r($_POST); echo '<br>'; //print_r($_SESSION); } if (isset($_POST['save'])) { $edit_text_image = new LastWorks(); $edit_text_image->last_works_id = $_POST['last_works_id']; $edit_text_image->last_works_title = $_POST['last_works_title']; $edit_text_image->last_works_status = $_POST['cb_visibility']; //var_dump($edit_text_image); //print_r($_POST); $edit_text_image->save(); echo "<div class='alert alert-success'> \n <i><strong>Text successfully updated. :)</strong></i>\n </div>"; $new = LastWorks::get($_POST['last_works_id']); //print_r($new); $_SESSION['change_text_last_works'] = $new; //print_r($_SESSION); } var_dump($_SESSION); ?> <img style="width: 200px; border-radius: 3px;" src="./../img/<?php echo $_SESSION['change_text_last_works']->last_works_image; ?> ">
<?php if (isset($_POST['cp_last_works'])) { $text_image = LastWorks::get($_POST['cp_last_works']); $_SESSION['change_image_last_works'] = $text_image; print_r($_POST); echo '<br>'; print_r($_SESSION); } // if click on button Save on this page if (isset($_POST['save'])) { $text_image = new LastWorks(); if (!empty($_FILES['fup_image'])) { move_uploaded_file($_FILES['fup_image']['tmp_name'], "./../img/" . $_FILES['fup_image']['name']); $text_image->last_works_id = $_POST['last_works_id']; $text_image->last_works_image = $_FILES['fup_image']['name']; //when data sent from the form we must update data in $_SESSION['change_image'] $_SESSION['change_image_last_works'] = $text_image; //insert updated object $text_image in $_SESSION['change_image'] again $text_image->save(); echo "<div class='alert alert-success'> \n <i><strong>Image successfully updated. :)</strong></i>\n </div>"; } //var_dump($_SESSION); } ?> <img style="width: 200px; border-radius: 3px;" src="./../img/<?php echo $_SESSION['change_image_last_works']->last_works_image; ?> ">