<?php

include_once("database.php");
$postData = file_get_contents("php://input");

if (isset($postData) && !empty($postData)) {
  $request = json_decode($postData);
  $username = trim($request->username);
  $data = trim($request->text);
  $filename = trim($request->filename);
  $lang = trim($request->language);
  $path = '../users/' . $username . '/' . trim($request->path) . '/' . $filename . $lang;

  if (unlink($path)) {
    $msg = "file successfully deleted";
    clearstatcache();
    echo json_encode($msg);
  }
  else {
        http_response_code(404);
  }


}
?>
