A
A
Artem Gartung2020-05-25 15:34:31
PHP
Artem Gartung, 2020-05-25 15:34:31

What could be the problem with screen capture in php?

Essentially, this code takes a fullscreen screenshot of the screen.

$path = $_SERVER["DOCUMENT_ROOT"].'/core/img/screen/';
$names = time().".png"; $im = imagegrabscreen();
imagepng($im, $path.$names);
imagedestroy($im);
$link = 'https://'.$_SERVER["HTTP_HOST"].'/core/img/screen/'.$names;


And on the local it works fine, but on the hosting server it refuses to work. What could be the problem?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ivan Nedzvetsky, 2020-05-25
@blackangelada

imagegrabscreen only works on Windows ( https://www.php.net/manual/ru/function.imagegrabsc...
As a rule, PHP hosting uses Linux, so the function does not work there.

F
FanatPHP, 2020-05-25
@FanatPHP

The problem is not understanding where PHP is running
From the link above, you can make a surprising discovery for yourself that PHP is running on the server.
When you find a screen at the server and you are interested in what is drawn on it, you can take a screenshot.
And if you are interested in the user's screen, then you have to remember where PHP works.

S
SagePtr, 2020-05-25
@SagePtr

On servers in most cases there is no screen at all

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question