query("SELECT * FROM site_manager where title = '".$_POST['title']."'"); if(!($chk->num_rows)) { $filename = time().$_FILES['myfile']['name']; // destination of the file on the server $destination = '../uploads/site_manager/' . $filename; // get the file extension $extension = pathinfo($filename, PATHINFO_EXTENSION); // the physical file on a temporary uploads directory on the server $file = $_FILES['myfile']['tmp_name']; $size = $_FILES['myfile']['size']; if (!in_array($extension, ['jpg', 'pdf', 'docx', 'jpeg', 'png'])) { echo ''; } elseif ($_FILES['myfile']['size'] > 100000000) { // file shouldn't be larger than 1Megabyte echo ''; } else { // move the uploaded (temporary) file to the specified destination if (move_uploaded_file($file, $destination)) { $sql = "INSERT INTO `site_manager` (`id`, `timestamp`, `title`, `file`) VALUES (NULL, CURRENT_TIMESTAMP, '".$_POST['title']."', '".$filename."')"; if (mysqli_query($con, $sql)) { echo ''; } } else { echo ''; } } } } if($_GET['action']=='del') { if(file_exists("../uploads/site_manager/".$_GET['file'])) unlink("../uploads/site_manager/".$_GET['file']); $con->query("DELETE FROM site_manager where id = '".$_GET['id']."'"); echo ''; } ?>

Site Download Manager