26 lines
883 B
PHP
26 lines
883 B
PHP
<?php
|
|
header('Content-Type: application/json');
|
|
|
|
include('include/headscript.php');
|
|
|
|
$dataURL = $_POST['dataURL'] ?? null;
|
|
$filename = $_POST['filename'] ?? null;
|
|
|
|
if (!$dataURL || !$filename) {
|
|
echo json_encode(['success' => false, 'message' => 'Dati mancanti']);
|
|
exit;
|
|
}
|
|
|
|
try {
|
|
$data = explode(',', $dataURL)[1];
|
|
$decodedData = base64_decode($data);
|
|
$filePath = '../photostrf/annotated/' . $filename; // Crea una sottocartella 'annotated' per le foto modificate
|
|
if (!file_exists('../photostrf/annotated')) {
|
|
mkdir('../photostrf/annotated', 0777, true);
|
|
}
|
|
file_put_contents($filePath, $decodedData);
|
|
echo json_encode(['success' => true, 'file_path' => $filePath, 'message' => 'Foto salvata con successo']);
|
|
} catch (Exception $e) {
|
|
echo json_encode(['success' => false, 'message' => 'Errore nel salvataggio: ' . $e->getMessage()]);
|
|
}
|