Post saved successfully in

Post saved successfully in

$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("/]*>(.*?)<\/h1>/i", $content, $m);

$title = $m[1] ?? ucwords(str_replace("-", " ", $slug));

if (file_put_contents($filePath, $html) === false) {

echo "Post saved successfully in /blog/posts/";

👤 Aurzon Editorial Team
Technology • Android • Windows • AI • Finance