korsygfhrfggfhfgfffgffg6655665dtggggggzangaiide
Elehhjhjjkjkfpf6df56fd65ffff
/
home2
/
sunpublicschools
/
public_html
/
SunShine_AdMin
/
Upload FileeE
HOME
<?php include 'header.php'; include 'config.php'; ?> <?php $id = $_GET['id']; $com_qry = "SELECT * from manag WHERE id = '$id'"; $com_res = mysqli_query($connect,$com_qry); if(mysqli_num_rows($com_res) > 0 ) { $com_data = mysqli_fetch_assoc($com_res); } ?> <div class="content-wrapper"> <div class="page-title"> <div> <p><i class="fa fa-eye"></i> Edit Co-Curricular Activities </p> </div> </div> <div class="card"> <?php if(isset($_POST['submit'])) { $id = $_GET['id']; $title = $_POST['title']; $title2 = $_POST['title2']; $descp = mysqli_real_escape_string($connect,$_POST['descp']); $target_dir = "images/about/"; $fileName = basename($_FILES["image"]["name"]); $tmp = explode(".", $fileName); $fileExtension = strtolower(end($tmp)); $target_file = $target_dir ."SUN".time().".".$fileExtension; $allowed = array("image/jpeg", "image/gif", "image/png"); if (!in_array($target_file, $allowed)) { $error_message = 'Only jpg, gif, and png files are allowed.'; if (isset($_FILES['image']['errors']) == 1) { echo "Sorry, your file was not uploaded."; } else { if (!move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) { $co_qery = "UPDATE manag set title = '$title',title2 = '$title2',descp = '$descp' WHERE id = '$id'"; $co_res = mysqli_query($connect,$co_qery); if($co_res) { ?> <script> alert('Updated Successfully'); window.location.replace("edit_manag.php?id=<?php echo $com_data['id'];?>"); </script> <?php } else { ?> <script> alert('Not Updated'); window.location.replace("edit_manag.php?id=<?php echo $com_data['id'];?>"); </script> <?php } } else { $co_qerys = "UPDATE manag set title = '$title',title2 = '$title2',descp = '$descp', image = '$target_file' WHERE id = '$id'"; $co_ress = mysqli_query($connect,$co_qerys); if($co_ress) { ?> <script> alert('Updated Successfully'); window.location.replace("edit_manag.php?id=<?php echo $com_data['id'];?>"); </script> <?php } else { ?> <script> alert('Not Updated'); window.location.replace("edit_manag.php?id=<?php echo $com_data['id'];?>"); </script> <?php } } } } } ?> <form method="post" action="" enctype="multipart/form-data"> <div class="row"> <div class="col-md-4"> <label>Edit Name</label> <input type="text" name="title" class="form-control" value="<?php echo $com_data['title'];?>"> </div> <div class="col-md-4"> <label>Edit Desingation</label> <input type="text" name="title2" class="form-control" value="<?php echo $com_data['title2'];?>"> </div> <div class="col-md-4"> <label>Edit Image</label> <input type="file" name="image" accept="image/jpg, image/jpeg, image/png" id="imageUpload" onchange="return fileValidation(this)"> </div> </div> <br> <div class="row"> <div class="col-md-12"> <label>Content</label> <textarea name="descp" rows="8" id="descp" class="form-control"><?php echo $com_data['descp'];?></textarea> </div> </div> <br> <div class="row"> <div class="col-md-12"> <img src="<?php echo $com_data['image'];?>" height="300" width="300"> </div> </div> <br> <div class="row"> <div class="col-md-4"> <input type="submit" name="submit" class="btn btn-success" value="Update"> </div> </div> </form> </div> </div> <script> function fileValidation(file){ var fileInput = file.value; var allowedExtensions = /(\.jpg|\.jpeg|\.png)$/i; if(!allowedExtensions.exec(fileInput)){ alert('Please upload file having extensions .jpeg/.jpg/.png only.'); file.value = ''; file.focus(); return false; }else{ return true; } } </script> <script src="js/jquery-2.1.4.min.js"></script> <script src="js/bootstrap.min.js"></script> <script src="js/plugins/pace.min.js"></script> <script src="js/main.js"></script> <script src="//cdn.ckeditor.com/4.9.2/standard/ckeditor.js"></script> <script type="text/javascript"> CKEDITOR.replace('descp'); CKEDITOR.replace('descp2'); </script>