https://gitlab.inria.fr/lyao/visinmotion
Tip revision: dd99681039060e6dcec83a378405faa3bc4527d3 authored by lyao on 09 December 2023, 20:43:19 UTC
readme updated
readme updated
Tip revision: dd99681
results.php
<?php //header("Cache-Control: no-cache, must-revalidate");
// session_start();
/*
This file will generate our CSV table. There is nothing to display on this page, it is simply used
to generate our CSV file and then exit. That way we won't be re-directed after pressing the export
to CSV button on the previous page.
*/
// convert the sent data into a flat array
$data = json_decode(file_get_contents('php://input'), true);
// extract the headers from the array
$headers = array_keys($data);
// our main csv file
$file_name = '../../results/results.csv';
$exists = file_exists($file_name);
// open a file handle to append new data
$handle = fopen($file_name, 'a+');
// if the file is empty, write a header line first
if (!$exists){
fputcsv($handle, $headers);
}
// add the received data to the file
fputcsv($handle, $data);
// close the file
fclose($handle);
exit;
?>
