$postsDir = $_SERVER['DOCUMENT_ROOT'] . "/blog/posts/";
$slug = preg_replace("/[^a-z0-9\-]/i", "", $_POST['slug'] ?? $_GET['slug'] ?? "");
$content = $_POST['content'] ?? file_get_contents("php://input");
/* FINAL FILE PATH (THIS IS THE KEY LINE) */
preg_match("/
$title = $m[1] ?? ucwords(str_replace("-", " ", $slug));
if (file_put_contents($filePath, $html) === false) {
echo "Post saved successfully in /blog/posts/";