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()]); }