File manager - Edit - /home/custbahd/mediagepr.com/admin/articles/edit_image/1.php
Back
<?php // including the database connection file include_once("../db/config.php"); if(isset($_POST['update'])) { $id = mysqli_real_escape_string($mysqli, $_POST['id']); $image1 = mysqli_real_escape_string($mysqli, $_FILES['image1']['name']); $target1 = "../images/".basename($_FILES['image1']['name']); // checking empty fields if(empty($image1)) { echo "<font color='red'>Please select image to update or <a href='index.php'>Go back</a>.</font><br/>"; } else { //updating the table $result = mysqli_query($mysqli, "UPDATE articles SET image1='$image1' WHERE id=$id"); if (move_uploaded_file($_FILES['image1']['tmp_name'], $target1)) { $msg = "Image uploaded successfully"; }else{ $msg = "There was a problem uploading image"; } } } ?> <?php //getting id from url $id = $_GET['id']; //selecting data associated with this particular id $result = mysqli_query($mysqli, "SELECT * FROM articles WHERE id=$id"); while($res = mysqli_fetch_array($result)) { $title = $res['title']; $image1 = $res['image1']; } ?> <html> <head> <title>Update Image</title> <style type="text/css"> .logo { margin-top: -20px; } .logo img { width: 60%; } /* If the screen size is 601px wide or more */ @media screen and (min-width: 601px) { .logo img { width: 25%; } } h4 { font-size: 20px; color: red; } tr { width: 100%; text-align: center; } .image-edit { width: 80%; border-radius: 10px; } input[type=submit] { color: white; border: none; border-radius: 5px; padding: 10px 40px; background: red; } /**Auto Load Image**/ .upload-wrapper { margin-bottom: 30px; width: 50%; height: 250px; border-radius: 10px; } .upload-btn-wrapper input[type=file] { font-size: 100px; width: 100%; height: 100%; margin-top: -250px; opacity: 0; z-index: 9; } .upload-btn-wrapper .btn img { margin-top: 20px; width: 100%; height: 100%; border-radius: 5px; object-fit: cover; } #output_image1 { margin-top: -250px; width: 100%; height: 100%; border-radius: 5px; } img#output_image1 { width: 100%; height: 100%; object-fit: cover; } /* If the screen size is 600px wide or less */ @media screen and (max-width: 600px) { .upload-wrapper { margin-bottom: 30px; width: 80%; height: 150px; border-radius: 10px; } #output_image1 { margin-top: -150px; } .upload-btn-wrapper input[type=file] { margin-top: -150px; } } .copyright-text { margin-top: 40px; font-size: 14px; text-align: center; } .copyright-text a{ color: red; text-decoration: none; } </style> </head> <body> <br> <br> <div align="center" class="logo"> <a href="../"><img src="../../../../assets/img/logo5.png" class="page-header text-center"></a> </div> <br> <br> <br> <div align="center"> <form name="form1" method="post" action="" enctype="multipart/form-data"> <table border="0"> <tr> <td><h5><?php echo $title; ?></h5></td> </tr> <tr> <td><h4>Image 1</h4></td> </tr> <tr> <td> <div class="upload-btn-wrapper" align="center"> <div class="upload-wrapper"> <div class="btn"> <?php if($image1 != ""): ?> <img src="../images/<?php echo $image1; ?>" class="image-edit"> <?php else: ?> <img src="../images/default.png" class="image-edit"> <?php endif; ?> </div> <input type="file" id="myFile" accept="image/*" onchange="preview_image1(event)" name ="image1"> <img id="output_image1" class="output_image1"> </div> </div> </td> </tr> <tr> <td><input type="hidden" name="id" value=<?php echo $_GET['id'];?>></td> </tr> <tr> <td> <br> <br> <input type="submit" name="update" value="Update Image"></td> </tr> </table> </form> </div> <div class="copyright-text"> <p>Media Age © <script>document.write(new Date().getFullYear());</script> Copyright. All Rights Reserved, <br> <br> Powered by <a href="https://customassistinc.com/" target="_blank">Custom Assist Inc.</a></p> </div> <!-- Upload Image JS --> <script src="../jquery/upload_img_script.js"></script> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Generation time: 2 |
proxy
|
phpinfo
|
Settings