0

I am sending an ajax request on dblick for creating the image of the screen where it is double clicked.I am ising imagegrabscreen() function of PHP to create image but instead of creating its image it is creates a black image.

dblclick(function (ev,ui)
                {
                var response = $.ajax({
                type:"POST",
                url: "grabImage.php",
                data:"name=John&location=Boston&function_name=img",
                complete: function(msg){
                    var resp = msg.responseText;
                    if(msg && msg.readyState != 4) { alert("Ready State :"+msg.readyState); return;  }
                    else{
                        //wb_load();
                        alert( "Data Saved: " + resp);

                }
                }
     });

                }
            );

GRAB IMAGE FUNCTION

function img()
    {
    $im = imagegrabscreen();
    imagepng($im, "C:\myscreenshot.png");
    //echo $im;
    //imagedestroy($im);
    return $im;
    define('imge',$im);
    }
  • 1
    Are you trying to return a screenshot of the windows desktop of the server you are running your website on? It seems the only legit use of imagegrabscreen() - also take a peek at: http://php.oregonstate.edu/manual/en/function.imagegrabscreen.php - there are some notes at the bottom about setting proper permissions to be able to capture the screen - has that been done? – gnarf Aug 11 '09 at 09:37

1 Answers1

0

http://us.php.net/manual/en/function.imagegrabscreen.php

For this to work your Apache service must be set to 'Allow service to interact with desktop' otherwise you will just get a blank image. To fix this right-click My Computer, select Manage/Services and Applications/Services - find the apache service (like Apache2) and right-click, select Properties - choose the Log on tab and check the 'Allow service to interact with desktop' checkbox. Restart Apache.

Mr. Smith
  • 5,489
  • 11
  • 44
  • 60
  • I am using XAMPP.I hope that won't make any effect. I did what u told me to do bt its not working. Same blabk image is formed –  Aug 11 '09 at 09:54