1

I am using 7.2.27 PHP version with Laravel 7.

Below code working on my local same configuration,

$captured = imagegrabscreen();
imagepng($captured, "~path/" . time() . ".png");
imagedestroy($captured);

But this code not working on live server it's throwing exception like, Fatal error: Uncaught Error: Call to undefined function imagegrabscreen() in ~file-path:11 Stack trace: #0 {main} thrown in ~file-path on line 11

I don't know what is the exact issue.

I also checked below answer but I don't know what is php_gd2.dll, https://stackoverflow.com/a/8715544/6656706

Edit: I also tried on AWS ec2 with xampp but not working ! I also tried by installing php_gd2.dll.

Any help will be appreciated !

Thanks.

5
  • What's the OS of the server? Commented Apr 19, 2020 at 9:47
  • Did you installed php-gd library right way on the server? Did you checked phpinfo() for supporting this library? Commented Apr 19, 2020 at 9:54
  • @Olivier Amazon Linux AMI Commented Apr 19, 2020 at 9:56
  • I wonder what you expect to see in that image Commented Apr 19, 2020 at 10:00
  • Yes, the screenshot is performed server-side of course, not client-side. Commented Apr 19, 2020 at 10:01

1 Answer 1

3
+50

If the server is on Linux, it can't work because imagegrabscreen() is only supported on Windows:

Note:

This function is only available on Windows.

Also note that the screenshot is performed on the server. It will not capture the user screen.

Sign up to request clarification or add additional context in comments.

6 Comments

So what about if I create instance of Windows Server 2019 ?
@JaydeepMor If you call the function on a Windows Server, it will capture the screen of that server (which is probably not what you want to do).
exceptions exist ofc, i have a windows server where i call imagegrabscreen() regurarly.. because i have a MMORPG game client running there 24/7 playing a game when i don't have time :P
Okay so any alternative way for achieve this ? Actually I need to capture user screen (Windows only).
@JaydeepMor A browser can't take a screenshot. Why do you need that anyway?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.