$fileName, 'size' => $fileStats['size'], 'lastModified' => date('c', $fileStats['mtime']), 'records' => $recordCount ]; } // Tarihe göre sırala (en yeni önce) usort($files, function($a, $b) { return strtotime($b['lastModified']) - strtotime($a['lastModified']); }); echo json_encode(['success' => true, 'files' => $files]); exit; case 'content': $fileName = basename($_GET['file'] ?? ''); if (empty($fileName)) { throw new Exception('Dosya adı belirtilmedi'); } $filePath = $bluetoothDataPath . '/' . $fileName; if (!file_exists($filePath) || pathinfo($filePath, PATHINFO_EXTENSION) !== 'txt') { throw new Exception('Dosya bulunamadı'); } $content = file_get_contents($filePath); echo json_encode(['success' => true, 'content' => $content]); exit; case 'download': $fileName = basename($_GET['file'] ?? ''); if (empty($fileName)) { http_response_code(400); die('Dosya adı belirtilmedi'); } $filePath = $bluetoothDataPath . '/' . $fileName; if (!file_exists($filePath) || pathinfo($filePath, PATHINFO_EXTENSION) !== 'txt') { http_response_code(404); die('Dosya bulunamadı'); } header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . $fileName . '"'); header('Content-Length: ' . filesize($filePath)); readfile($filePath); exit; } } catch (Exception $e) { http_response_code(500); echo json_encode(['success' => false, 'error' => $e->getMessage()]); exit; } } ?>
/bluetooth_data klasöründeki tüm text dosyaları otomatik olarak taranıyor.
PHP backend ile bluetooth_data klasörü taranıyor...