D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home2
/
technoi4
/
www
/
demo
/
admin
/
Filename :
edit_pdf.php
back
Copy
<?php require_once('header.php'); require('config.php'); ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Update Product_Image</title> </head> <?php include('sidebar.php'); ?> <!-- sidebar-wrapper --> <main class="page-content"> <div class="container"> <?php $ii = $_GET['id']; $query = "SELECT pdf_image.*, product.pid, product.product_name FROM `pdf_image` LEFT JOIN product ON pdf_image.pid=product.pid where pdf_image.id=$ii"; $res = mysqli_query($conn, $query); $data = mysqli_fetch_assoc($res); mysqli_error($conn); ?> <form method="post" enctype="multipart/form-data"> <div class="row"> <div class="col-md-12"> <input type="hidden" name="oi" value="<?php echo $ii; ?>"> <div> <img loading="lazy" class="img-fluid" src="../images/pdf.png" style="height: 2rem;"><a href="img/pdf_image/'.$row['image'].'" target="_blank"> <?php echo $data['image']; ?> <a/> </div> <div class="form-group"> <label for="exampleI">Product Name</label> <input type="hidden" class="form-control" name="pid" value="<?php echo $data['pid']; ?>" readonly> <input type="text" class="form-control" value="<?php echo $data['product_name']; ?>" readonly> </div> <div class="form-group"> <label for="exampleFormControlFile1">Upload Image</label> <input type="file" class="form-control-file" id="exampleFormControlFile1" name="newimg"> </div> </div> </div> <button name="update" class="btn btn-primary">Update</button> </form> <script> $('#selector').change(function(){ if($(this).val() == "no" ){ $('.otherprof').slideUp(); }else{ $('.otherprof').slideDown(); } }); </script> <script> $('#selector_new').change(function(){ if($(this).val() == "no" ){ $('.other_prof').slideUp(); }else{ $('.other_prof').slideDown(); } }); </script> <?php if (isset($_POST['update'])) { $oi = $_POST['oi']; $pid = $_POST['pid']; $newimg = $_FILES['newimg']['name']; if (!empty($newimg) && isset($newimg)!=NULL) { $dir = 'img/pdf_image/'; $extension = array("jpeg", "jpg", "png", "pdf", "gif", "JPG"); $ext = pathinfo($_FILES["newimg"]["name"], PATHINFO_EXTENSION); $pimage = $_FILES['newimg']['name']; require('config.php'); if (in_array($ext, $extension)) { $query = "UPDATE `pdf_image` SET `pid`='$pid', `image`='$newimg' where id='$oi'"; $res = mysqli_query($conn, $query); if ($res) { move_uploaded_file($_FILES['newimg']['tmp_name'], "$dir" . $newimg); echo '<script type="text/JavaScript"> window.location="pdf_image.php"</script>'; } else echo "eror = " . mysqli_error($conn); } else { echo "Please, Select the file from the following extension: jpeg, jpg, png, gif"; } } else { $query = "UPDATE `pdf_image` SET `pid`='$pid' where id='$oi'"; $res = mysqli_query($conn, $query); if ($res) { echo '<script type="text/JavaScript"> window.location="pdf_image.php"</script>'; } } } ?> </div> </main> <!-- page-content" --> <?php include('footer.php'); ?>