$id, 'name' => $image['path']); $id++; } return $res; } $output = []; try { $output = dirlist(@$_GET['dir']); } catch (Exception $e) { $output['error'] = true; $output['exception'] = $e; } header("Content-Type: application/json"); echo json_encode($output); ?>