Send Photos to Frame
Select photos from your iPhone library to instantly display on your Microsoft Surface digital frame.
'error', 'message' => 'Invalid file format. Only JPEG, PNG, HEIC, and WEBP supported.']); exit; } $ext = pathinfo($file['name'], PATHINFO_EXTENSION); $filename = 'photo_' . time() . '_' . bin2hex(random_bytes(4)) . '.' . strtolower($ext); $targetPath = $uploadDir . $filename; if (move_uploaded_file($file['tmp_name'], $targetPath)) { echo json_encode(['status' => 'success', 'filename' => $filename]); } else { echo json_encode(['status' => 'error', 'message' => 'Failed to save uploaded file.']); } exit; } // API Endpoint: Retrieve JSON list of uploaded photos if (isset($_GET['api']) && $_GET['api'] === 'photos') { header('Content-Type: application/json'); $files = array_diff(scandir($uploadDir), array('.', '..')); $photos = []; foreach ($files as $f) { if (preg_match('/\.(jpg|jpeg|png|heic|webp)$/i', $f)) { $photos[] = [ 'url' => 'uploads/' . $f, 'time' => filemtime($uploadDir . $f) ]; } } // Sort newest first usort($photos, function($a, $b) { return $b['time'] - $a['time']; }); echo json_encode(array_values($photos)); exit; } ?>
Select photos from your iPhone library to instantly display on your Microsoft Surface digital frame.