D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
balhit1357
/
balhit.ac.in
/
bal-vidyalaya
/
admin
/
Filename :
circularupdate.php
back
Copy
<?php require_once 'include/connection.php'; $id = $_POST["txtSr"]; $desc = str_replace("'", "\'", $_POST["x_descrip"]); $title = str_replace("'", "\'", $_POST["title"]); $pdf = $_FILES["myfile"]["name"]; // $ofile = $_POST["Oldfile"]; $date = date("d-m-Y"); if (!empty($pdf)) { $imgfile = $_FILES["myfile"]["name"]; // get the image extension // $extension = substr($imgfile, strlen($imgfile) - 4, strlen($imgfile)); $extension = strtolower(substr($imgfile, strpos($imgfile, '.'))); // allowed extensions $allowed_extensions = array(".jpg", ".jpeg", ".png", ".gif", ".pdf"); // Validation for allowed extensions if (!in_array($extension, $allowed_extensions)) { ?> <script> alert('Invalid format. Only jpg /jpeg /png /gif /pdf format allowed'); document.location.href = "circularreport.php"; </script> <?php die(); } else { //rename the image file $imgnewfile = md5($imgfile) . $extension; // Code for move image into directory move_uploaded_file($_FILES["myfile"]["tmp_name"], "textdoc/" . $imgnewfile); // Query for insertion data into database $rs = mysqli_query($link, "UPDATE `cir_detail` SET `title`='$title', `description`='$desc', `date`='$date', `datapath`='$imgnewfile' WHERE `sr_no`='$id' "); } } else { $rs = mysqli_query($link, "UPDATE `cir_detail` SET `title`='$title', `description`='$desc', `date`='$date' WHERE `sr_no`='$id'"); } // die(); // if (!empty($pdf)) { // $target_dir = "textdoc/"; // $pdf = $_FILES["myfile"]["name"]; // list($txt, $ext) = explode(".", $pdf); // date_default_timezone_set("Asia/Calcutta"); // $currentdate = date("d M Y"); // $file = time() . substr(str_replace(" ", "_", $txt), 0); // $info = pathinfo($file); // $filename = $file . "." . $ext; // $fileToUpload = $target_dir . $filename; // $file_typee = $_FILES["myfile"]["type"]; // //echo $file_typee; // /*$allowedExts = array('application/pdf','application/msword', 'application/doc', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'text/plain');*/ // $allowedExts = array('image/gif', 'image/jpeg', 'image/jpg', 'image/png', 'application/pdf', 'application/msword'); // $explode = explode(".", $_FILES['myfile']['name']); // $extension = end($explode); // $upl = 1; // if (in_array($file_typee, $allowedExts)) { // move_uploaded_file($_FILES['myfile']['tmp_name'], $fileToUpload); // } // $rs = mysqli_query($link, "update cir_detail set `title`='$title', `description`='$desc', `date`='$date', `datapath`='$filename' where sr_no='$id' "); // } else { // $rs = mysqli_query($link, "update cir_detail set `title`='$title', `description`='$desc', `date`='$date', `datapath`='$ofile' where sr_no='$id' "); // } ?> <script> alert('Updated Successfully'); window.location.href = "circularreport.php"; </script>