30 lines
971 B
PHP
30 lines
971 B
PHP
<?php
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$data = json_decode(file_get_contents('php://input'), true);
|
|
|
|
// Uložte hodnotu obličeje (a další data) na serveru
|
|
file_put_contents('adf/data.json', json_encode($data));
|
|
|
|
echo json_encode(['success' => true]);
|
|
} elseif ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
|
// Kontrola existence souboru
|
|
$filePath = 'adf/data.json';
|
|
if (file_exists($filePath)) {
|
|
// Načtení obsahu souboru
|
|
$fileContent = file_get_contents($filePath);
|
|
|
|
// Odeslání obsahu zpět klientovi
|
|
header('Content-Type: application/json');
|
|
header('Access-Control-Allow-Origin: *'); // Povolení Cross-Origin požadavků
|
|
echo $fileContent;
|
|
} else {
|
|
echo json_encode(['error' => 'File not found']);
|
|
}
|
|
} else {
|
|
echo json_encode(['error' => 'Invalid request method']);
|
|
}
|
|
|
|
// Ladící výstup
|
|
error_log(print_r($_POST, true));
|
|
error_log(print_r($_FILES, true));
|