File "script_read.php"

Full Path: /home/analogde/www/Diabete/Provisoire/script_read.php
File size: 1.01 KB
MIME-type: text/x-php
Charset: utf-8

<?php
header('Content-Type: application/json');

$data = json_decode(file_get_contents('php://input'), true);

    if (isset($data['fileName'])) 
    {
        $fileName = $data['fileName'];
        //    $filePath = 'path_to_save/' . $fileName . '.json'; // Remplacez 'path_to_save' par le chemin où vous avez sauvegardé le fichier

        //$filePath = $fileName . '.json'; // Remplacez 'path_to_save' par le chemin où vous avez sauvegardé le fichier

        $filePath = $fileName ;// Remplacez 'path_to_save' par le chemin où vous avez sauvegardé le fichier

        if (file_exists($filePath)) 
        {
            $fileContent = file_get_contents($filePath);
            echo json_encode(['status' => 'success', 'data' => json_decode($fileContent, true)]);
        } 
        else 
        {
            echo json_encode(['status' => 'error', 'message' => 'Le fichier n\'existe pas.']);
        }
    } 
    else 
    {
        echo json_encode(['status' => 'error', 'message' => 'Nom de fichier manquant.']);
    }
?>