<?php

include "db.php";

$id = $_POST['id'] ?? '';

if($id == '') exit;

$q = mysqli_query($conn,"SELECT * FROM media WHERE id='$id'");
$d = mysqli_fetch_assoc($q);

if(!$d) exit;

$file = __DIR__."/uploads/".$d['type']."/".$d['gambar'];

if(file_exists($file)){
unlink($file);
}

mysqli_query($conn,"DELETE FROM media WHERE id='$id'");

echo "ok";

?>