Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
To save a browser screenshot on a PHP server, capture pixels into a canvas in JavaScript, export the canvas with toBlob(), upload the resulting Blob as multipart form data, and validate it on PHP before moving it into storage. Use html2canvas when you need an HTML element or page region. Use navigator.mediaDevices.getDisplayMedia() when the user must select an actual screen, window, or tab.
Choose what “screenshot” means
There are two different jobs that are often described as a screenshot:
- DOM capture: Reconstruct an element or page region from its HTML and styles with
html2canvas. This does not capture browser chrome and is not guaranteed to match every rendered layer pixel for pixel. - Display capture: Ask the user to share a screen, window, or tab with
getDisplayMedia(), show the resulting stream in a video element, and draw a frame into a canvas.
Deciding this first prevents a common implementation error: using a DOM renderer when the requirement is an exact user-selected display, or requesting screen-sharing permission when an in-page component is all that is needed.
Free tools Windows power users keep installed
One-click scans. No signup required.
Capture an HTML element with html2canvas
Client-side page
Load html2canvas, select the element, render it, and upload a Blob. The scale option uses the device pixel ratio for sharper output. useCORS: true can allow images whose servers explicitly permit cross-origin use.
#1 Best Overall
- 【1080P 60FPS Video Capture Card】 This HDMI game capture card is based on USB3.0 high speed transmission port, input resolution up to 4K@30HZ, output resolution up to 2K@30Hz or 1920×1080@60Hz. Type c and USB interface can meet most of the devices in daily life. Easily meet the online capture, real-time recording, online meetings, live gaming and other functions, so you have a better visual enjoyment. Note: For capture use only; requires capture software to function and is not intended for direct screen casting to a monitor or TV
- 【Ultra Low Latency Screen Sharing】 HDMI capture card is made of good quality aluminum alloy with strong heat dissipation, allowing you to enjoy ultra low latency while live gaming or video recording or live streaming, avoiding blue screens and lag. This HDMI to USBC capture card supports easy recording of good quality audio or HD video and transferring it to your computer or streaming platform, allowing you to record 60 fps HD video directly on your hard drive and real-time preview
- 【Plug and Play, Easy to Carry】 This HDMI 1080P video capture card does not require any additional drivers or external power supply, just plug and play for fast capture. The capture card is small and lightweight, so you can put it in your bag for emergencies, making it very portable for outdoor live streaming. It's also a great way to share content in game recording, video conference, video recorder and online teaching
- 【Wide Compatibility USB Capture Card】 Easily streams to Facebook, Youtube or Twitch. With the connection, this HDMI to USB C/3.0 video capture devices can be working on several Operating Systems and various software: Windows 7/ 8/ 10, Mac OS or above, Linux, Android, Laptop, Xbox One, PS3/PS4/PS5, Camera, DVDs, Set Top Box, Webcame, DSLR, Switch/Switch 2, TV BOX, HDTV, Potplayer/VLC, ZOOM, OBS Studio etc.
- 【Package Content & Note】 1x HD Audio Capture Card , 1x USB 3.0 to USB C Adapter (A-side 3.0, B-side 2.0), 1x user manual. Please note that you need to restart the OBS Studio software after the audio setup is complete, otherwise it will result in no sound output. When using an adapter, if the device is recognized as USB 2.0, try using the other side with the USB-C port. Simply flip the capture card and reconnect it to be recognized as USB 3.0
<button id="save-shot" type="button">Save screenshot</button>
<section id="capture">
<h1>Order summary</h1>
<p>This entire section will be rendered into an image.</p>
</section>
<p id="status" role="status"></p>
<script src="https://cdn.jsdelivr.net/npm/html2canvas@latest/dist/html2canvas.min.js"></script>
<script>
const button = document.querySelector('#save-shot');
const status = document.querySelector('#status');
button.addEventListener('click', async () => {
button.disabled = true;
status.textContent = 'Rendering…';
try {
const canvas = await html2canvas(document.querySelector('#capture'), {
scale: window.devicePixelRatio,
useCORS: true,
backgroundColor: '#ffffff'
});
const blob = await new Promise((resolve, reject) => {
canvas.toBlob(result => result ? resolve(result) : reject(new Error('Canvas export failed')), 'image/png');
});
const form = new FormData();
form.append('shot', blob, 'screenshot.png');
const response = await fetch('/save-screenshot.php', {
method: 'POST',
body: form,
credentials: 'same-origin'
});
const result = await response.json();
if (!response.ok) throw new Error(result.error || 'Upload failed');
status.textContent = `Saved as ${result.file}`;
} catch (error) {
status.textContent = error.message;
} finally {
button.disabled = false;
}
});
</script>
Do not set a manual Content-Type header on this request. The browser adds the multipart boundary when it serializes FormData.
Why cross-origin images can fail
A canvas becomes tainted when it contains pixels from another origin that did not grant CORS access. A tainted canvas cannot be read or exported, so toBlob() or toDataURL() can fail. The remote image must send an appropriate CORS response header, and the image request must be made in a CORS-compatible way. If you control neither server, proxy the asset through your own origin or omit it from the capture.
Rank #2
- [Enhanced 4K-1080P Video Capture Experience] Capture the Magic: Elevate your video recordings to new heights with our upgraded anti-static 1080P Video Capture Card. Immerse yourself in stunning visuals, supporting HDMI input at 4K 60FPS and USB output for capturing in 1080P, complete with rich stereo sound. Enjoy crystal-clear video recordings, dynamic gaming live streams, and professional conference broadcasts. Note: HDMI resolution: Max input can be 3840×2160@30Hz / Video output resolution: Max output can be 1920×1080@30Hz
- [Seamless Real-Time Preview] Stay in the Moment: Our advanced ultra-low latency technology ensures seamless real-time transmission of video streams. Experience instant, lag-free previews, allowing you to capture every detail precisely. Effortlessly record video directly to your hard disk, all without compromising on quality or introducing any delays.
- [Versatility and Broad Compatibility] Your Creative Hub: Connect your DSLR, camcorder, or action camera to a wide range of operating systems, including Windows, MacOS, and Linux. Unlock a world of possibilities with real-time streaming to popular platforms like Twitch, Youtube, OBS, Zoom, Potplayer, and VLC, giving you the tools to share your content effortlessly.
- [Effortless Plug and Play] Simplicity Redefined: Say goodbye to complex installations. Our plug-and-play design eliminates the need for drivers or external power supplies. Seamlessly integrate high-definition acquisition into various scenarios, whether it's educational recordings, immersive gaming, precise medical imaging, captivating live streams, or professional broadcasting.
- [Seize Every Detail with Precision] Unleash your creativity and attention to detail with our video capture card. Capture every nuance, every color, and every moment with precision, thanks to the enhanced capabilities of our technology. Whether you're a content creator, a gamer, or a professional, our capture card empowers you to seize the finest elements and bring them to life in your recordings and live streams.
Capture a real screen, window, or tab
getDisplayMedia() requires a secure HTTPS context (localhost is generally treated as secure) and a user permission prompt. Browsers limit support and the user, not the page, chooses the surface. Start it from a button click so the call has transient user activation.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →<button id="share-screen" type="button">Choose screen or tab</button>
<video id="preview" autoplay muted playsinline hidden></video>
<canvas id="screen-canvas" hidden></canvas>
<script>
const share = document.querySelector('#share-screen');
const video = document.querySelector('#preview');
const canvas = document.querySelector('#screen-canvas');
share.addEventListener('click', async () => {
let stream;
try {
stream = await navigator.mediaDevices.getDisplayMedia({
video: { cursor: 'include' },
audio: false
});
video.srcObject = stream;
video.hidden = false;
await video.play();
// Wait for dimensions before drawing the first frame.
if (!video.videoWidth) {
await new Promise(resolve => video.addEventListener('loadedmetadata', resolve, { once: true }));
}
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
const blob = await new Promise((resolve, reject) => {
canvas.toBlob(result => result ? resolve(result) : reject(new Error('Canvas export failed')), 'image/png');
});
const form = new FormData();
form.append('shot', blob, 'display-capture.png');
const response = await fetch('/save-screenshot.php', { method: 'POST', body: form });
if (!response.ok) throw new Error('Server rejected the upload');
console.log(await response.json());
} catch (error) {
console.error(error);
} finally {
if (stream) stream.getTracks().forEach(track => track.stop());
video.srcObject = null;
video.hidden = true;
}
});
</script>
Handle cancellation as a normal outcome: a user closing the picker commonly produces a permission or abort error. Provide the DOM-capture path as a fallback when the browser does not expose getDisplayMedia() or your product cannot depend on screen-sharing support.
Rank #3
- 【4K HDMI Input, 2K@30Hz Recording】Powered by a true USB 3.0 high-speed interface, the capture card supports up to 4K@30Hz HDMI input and records at 2K@30Hz or 1080P@60Hz. Perfect for gamers, streamers, and professionals who need crisp, smooth video for live streaming, gameplay recording, or online meetings.
- 【Ultra Low Latency Screen Sharing】Built with a premium aluminum alloy shell and advanced chipset for stable heat dissipation, ensuring ultra-low latency transmission. Capture high-quality video and dual-channel audio in real time—no lag, no frame drop—ideal for Twitch, YouTube, or OBS streaming.
- 【Easy Plug and Play, Compact & Portable】No driver or external power required—just plug and play via USB 3.0 or Type-C connection to your Windows or macOS computer. Lightweight and compact design makes it easy to carry for outdoor streaming, live shows, or mobile recording setups.
- 【Wide Compatibility & Multi-Device Support】Compatible with Windows 7 8 10 11, macOS, Linux,Android and supports most popular software such as OBS, Zoom, VLC, Twitch Studio, and more. Works seamlessly with PS4, PS5, Xbox, Switch, DSLR cameras, TV boxes, and other HDMI-output devices for streaming to YouTube, Twitch, etc.
- 【What You Get】Includes: HDMI Capture Card, USB 3.0 to USB-C Adapter, User Manual. Tips: Make sure your tablet’s OTG function is enabled before connecting. Test your HDMI device with a monitor first to confirm video and audio output, then connect to the Video Capture Card for recording.
Export efficiently: toBlob versus toDataURL
canvas.toDataURL('image/png') returns a data URL containing the complete image as an in-memory string. It is convenient for a small preview or download, but large images consume more memory and require base64 processing. canvas.toBlob() creates binary data and is the better default for uploads. PNG is lossless; request image/jpeg or image/webp when smaller files matter and your browser/server pipeline supports that format.
// Small preview only
const dataUrl = canvas.toDataURL('image/png');
document.querySelector('#preview-image').src = dataUrl;
// Production upload
const blob = await new Promise(resolve => canvas.toBlob(resolve, 'image/webp', 0.85));
Match the filename extension you send to the actual MIME type. Never treat a client-provided filename or MIME field as proof of what the bytes contain.
Rank #4
- 【1080P HD High Quality】Capture resolution up to 1080p for video source and it is ideal for all HDMI devices such as PS4, PS3, Xbox One, Xbox 360, Wii U, DVDs, DSLR, Camera, Security Camera and set top box. Note: Video input supports 4K30/60Hz and 1080p120/144Hz. Does not support 4K120Hz/144Hz. Output supports up to 2K30Hz.
- 【Plug and Play】No driver or external power supply required, true PnP. Once plugged in, the device is identified automatically as a webcam. Detect input and adjust output automatically. Won't occupy CPU, optional audio capture. No freeze with correct setting.
- 【Compatible with Multiple Systems】suitable for Windows and Mac OS. High speed USB 3.0 technology and superior low latency technology makes it easier for you to transmit live streaming to Twitch, Youtube, Facebook, Twitter, OBS, Potplayer and VLC.
- 【HDMI LOOP-OUT】Based on the high-speed USB 3.0 technology, it can capture one single channel HD HDMI video signal. There is no delay when you are playing game live.
- 【Support Mic-in for Commentary】Rybozen capture card has microphone input and you can use it to add external commentary when playing a game. Please note: it only accepts 3.5mm TRS standard microphone headset.
PHP endpoint: validate before storing
Save the following as save-screenshot.php. Create an uploads directory that the PHP process can write to. Prefer a directory outside the public web root; if files must be public, disable script execution there and serve downloads through a controlled route.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errors<?php
header('Content-Type: application/json; charset=utf-8');
function fail(int $status, string $message): never {
http_response_code($status);
echo json_encode(['error' => $message]);
exit;
}
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
fail(405, 'POST required');
}
if (!isset($_FILES['shot']) || !is_array($_FILES['shot'])) {
fail(400, 'Missing shot upload');
}
$file = $_FILES['shot'];
if (is_array($file['error'])) {
fail(400, 'Invalid upload structure');
}
if ($file['error'] !== UPLOAD_ERR_OK) {
fail(400, 'Upload failed');
}
if (!is_uploaded_file($file['tmp_name'])) {
fail(400, 'Not a valid HTTP upload');
}
$maxBytes = 5_000_000;
if ($file['size'] < 1 || $file['size'] > $maxBytes) {
fail(413, 'Image exceeds the 5 MB limit');
}
$finfo = new finfo(FILEINFO_MIME_TYPE);
$mime = $finfo->file($file['tmp_name']);
$extensions = [
'image/png' => 'png',
'image/jpeg' => 'jpg',
'image/webp' => 'webp'
];
$extension = $extensions[$mime] ?? null;
if ($extension === null) {
fail(415, 'Only PNG, JPEG, and WebP images are accepted');
}
$directory = __DIR__ . '/uploads';
if (!is_dir($directory) && !mkdir($directory, 0750, true)) {
fail(500, 'Storage directory unavailable');
}
$name = bin2hex(random_bytes(16)) . '.' . $extension;
$destination = $directory . DIRECTORY_SEPARATOR . $name;
if (!move_uploaded_file($file['tmp_name'], $destination)) {
fail(500, 'Could not save upload');
}
echo json_encode(['file' => $name]);
finfo inspects the temporary file instead of trusting $_FILES['shot']['type']. The random server-side name prevents collisions and avoids using attacker-controlled path text. move_uploaded_file() accepts only files uploaded through PHP’s HTTP POST mechanism and can overwrite an existing destination, which is why the destination must be unique.
Best Value
- AV TO USB Converter: Capture videos and audios from VHS, VCR, Hi8, DV tapes to a PC, with the help of our USB Video Converter. Save room while digitizing your favorite old memories
- Quality Capture Card: Our USB Video Capture Card converting anolog RCA composite input into HD 720P USB output and capturing audio without any sound card. Advanced signal processing technology provides you with great precision, colors, resolutions, and details.
- Plug and Play: Automatically install the driver once you hook up this RCA to USB Converter to a PC. No external power is needed. User-friendly and easy to operate
- Wide Compatibility: The Video Capture Card can work with video devices with RCA connector or S-Video connector, such as VHS, VCR, Hi8, camcorder, compatible with Windows and Mac OS. Support video formats like NTSC, PAL, and support brightness, contrast, hue, and saturation control
- Note: The Video Converter is used with acquisition software. We recommend OBS Studio or PotPlayer for Windows, and QuickTime Player for Mac. They can be downloaded for free online. Please operate according to the steps in User Manual or contact us if you have any questions
Production safeguards and operational details
- Authentication: Require the same login or a CSRF token when screenshots are private. For cross-origin clients, configure CORS deliberately rather than reflecting arbitrary origins.
- Limits: Enforce both application and PHP limits (
upload_max_filesizeandpost_max_size). A high-DPI full-page canvas can exceed several megabytes. - Storage: Generate names on the server, set restrictive permissions, and apply retention or quotas. Do not allow uploaded files to execute as PHP.
- Privacy: Screen captures may contain passwords, personal data, or confidential tabs. Explain what is shared and delete temporary files when processing ends.
- Reliability: Return JSON for both success and errors, check HTTP status before parsing a success response, and retry only transient network failures. Do not blindly retry a request that may have stored a file unless you use an idempotency key.
- Performance: Capture only the required region, avoid unnecessary device-pixel-ratio scaling on very large pages, prefer
toBlob(), and consider WebP or JPEG for photographic content.
Common failures and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Blank or incomplete DOM image | Fonts, lazy content, animations, or unsupported CSS were not ready. | Wait for content and fonts, temporarily disable animation, and capture after the target is fully rendered. |
| Security error when exporting | A cross-origin image tainted the canvas. | Enable CORS on the image origin, proxy the asset, or remove it from the capture. |
getDisplayMedia is undefined |
Browser does not support the API or the page is not secure. | Use HTTPS and feature-detect the API; offer html2canvas as a fallback. |
| Permission denied or picker closes | The user cancelled, or the call was not made from a user gesture. | Call from a click and show a non-error cancellation message. |
| PHP reports upload error 1 or 2 | PHP or the form exceeded configured size limits. | Raise limits carefully or reduce capture dimensions and output quality. |
| HTTP 415 from PHP | Detected MIME type is not on the allowlist. | Send PNG, JPEG, or WebP and ensure the bytes match the extension. |
| Move fails | Directory is missing, unwritable, or the temporary upload is invalid. | Check permissions, create the directory, verify is_uploaded_file(), and inspect server logs. |
Or skip the browser setup
ScreenshotNeo provides a website screenshot API and MCP server. One request captures a URL as PNG, JPEG, WebP, or PDF without building a browser page and upload endpoint:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo documentation for all options. The same endpoint is available from Python:
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
And Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const bytes = new Uint8Array(await res.arrayBuffer());
await Bun.write('shot.webp', bytes);
Before capture, ScreenshotNeo accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be disabled. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server includes take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Create a free ScreenshotNeo account.
Recommended Free Tools
When to use each approach
| Requirement | Best fit |
|---|---|
| Capture one component already rendered in your page | html2canvas and a Blob upload |
| Capture a user-selected monitor, window, or tab | getDisplayMedia, with explicit permission |
| Capture a public URL from a backend job or AI agent | ScreenshotNeo API or MCP server |
Frequently Asked Questions
Can PHP take the screenshot by itself?
No. PHP can receive and store image bytes, but a browser or rendering service must first produce the client-side pixels.
Should I store the returned filename in a database?
For an application that needs ownership, search, or retention rules, store the generated identifier and metadata in a database while keeping the image outside executable upload paths.
Can I capture an entire page with getDisplayMedia?
Only if the user selects a display or window that contains it. For a programmatic full-page DOM capture, render the page element and account for its full dimensions instead.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

