Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

take a screenshot of the current screen and save it as a png image through php

Hello all I have an requirement that clients needs screenshot of current webpage when he clicks a button "sceencapture" Although i googled for it result come out in this way

$im = imagegrabscreen();
imagepng($im, "myscreenshot.png");
imagedestroy($im);

in the manual on php.net link here having a note :This function is only available on Windows. please help ..

like image 437
Rajeev Ranjan Avatar asked Sep 06 '25 05:09

Rajeev Ranjan


1 Answers

This is not possible using PHP, as PHP executes on the server and a screenshot by definition must be done on the client. You could take a screenshot on the client side using client-side technology like the html2canvas library. Then you could send the screenshot to your server side PHP code if you wanted to.

like image 79
Erik Schierboom Avatar answered Sep 10 '25 20:09

Erik Schierboom