Add pedoman content and editor assets
This commit is contained in:
51
pedoman/editpdf.php
Normal file
51
pedoman/editpdf.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
include('authsession.php');
|
||||
|
||||
if(isset($_POST['submit'])){
|
||||
|
||||
$sqlisi="SELECT * FROM menu WHERE id='".$_GET['id']."'";
|
||||
$queryisi=mysqli_query($koneksi, $sqlisi);
|
||||
$isi=mysqli_fetch_array($queryisi);
|
||||
|
||||
$target_dir = "uploads/";
|
||||
$target_file = $target_dir.basename($_FILES["pdf"]["name"]);
|
||||
$uploadOk = 1;
|
||||
echo $_FILES["pdf"]["tmp_name"];
|
||||
echo $_FILES["pdf"]["name"];
|
||||
echo $_FILES["pdf"]["error"];
|
||||
|
||||
$fileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
|
||||
|
||||
// Check if file already exists
|
||||
if (file_exists($target_file)) {
|
||||
echo "Sorry, file already exists.";
|
||||
$uploadOk = 0;
|
||||
}
|
||||
if($fileType != "pdf" ) {
|
||||
echo "Sorry, only PDF";
|
||||
$uploadOk = 0;
|
||||
}
|
||||
// Check if $uploadOk is set to 0 by an error
|
||||
if ($uploadOk == 0) {
|
||||
echo "Sorry, your file was not uploaded.";
|
||||
// if everything is ok, try to upload file
|
||||
} else {
|
||||
if (move_uploaded_file($_FILES["pdf"]["tmp_name"], $target_file)) {
|
||||
echo "The file ".basename( $_FILES["pdf"]["name"])." has been uploaded.";
|
||||
} else {
|
||||
echo "Sorry, there was an error uploading your file.";
|
||||
echo $_FILES["pdf"]["error"];
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "UPDATE menu SET isimenu='$target_file' WHERE id='".$_GET['id']."'";
|
||||
$query = mysqli_query($koneksi, $sql);
|
||||
if ($query) {
|
||||
$message = 'Data berhasil disimpan!';
|
||||
header('Location: admin.php?pesan='.$message.'&tipe=sukses¬if=ok');
|
||||
} else {
|
||||
$message = 'Data gagal disimpan! Mohon diisi ulang.';
|
||||
header('Location: admin.php?pesan='.$message.'&tipe=alert¬if=ok');
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user