false, 'error' => 'Method not allowed']); exit; } $raw = file_get_contents('php://input'); $data = json_decode($raw, true); if ($data === null) {echo json_encode(['ok' => false, 'error' => 'Invalid JSON']);exit;} // Save store data to storage/store.json (overwritten) $dir = __DIR__.'/storage'; if (!is_dir($dir)) { @mkdir($dir, 0755, true); } $path = $dir.'/store.json'; file_put_contents($path, json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); echo json_encode(['ok' => true, 'path' => 'api/storage/'.basename($path)]);