-2

Possible Duplicate:
Website screenshots using PHP

how can i take a screen shot and save it in PHP? I wana take a screen shot a users screen and save it to user's machine when he/she clicks on save button. Is there any way to do this??

Community
  • 1
  • 1
  • 2
    If you searched for "screenshot php" on stackoverflow, you'd find hundreds of duplicates telling you it cannot be done. – Leigh Aug 02 '12 at 08:38
  • see http://stackoverflow.com/questions/757675/website-screenshots-using-php – kawashita86 Aug 02 '12 at 08:39
  • 1
    `onclick="alert('Please press Print Screen Key on your keyboard.');"` – xdazz Aug 02 '12 at 08:39
  • 1
    PHP is the wrong choice of a programming language for such a feature. Even if you'll find a way to capture and save a screenshot, you still need a webserver running on the clients PC. Try some other scripting language, e.g. Python… @Leigh Well you can; see the other linked questions for different solutions; for example: http://www.os-cms.net/blog/view/5/how-to-create-a-screen-dump-with-php-on-linux – feeela Aug 02 '12 at 08:39
  • @Leigh — No, you'll find lots of people asking how to take a screenshot directly with PHP (and not on the visitor's computer) … as per the first and third comment. – Quentin Aug 02 '12 at 08:40
  • @feeela — PHP is rarely used without a webserver, not *impossible* (or even hard) to use without one. – Quentin Aug 02 '12 at 08:41
  • @Quentin: I find no information that puts the users computer in relatation to the servers computer, so how can you say, the user is not the programmer here creating that system? – hakre Aug 02 '12 at 08:41
  • @Quentin "[when the user] clicks on save button" How would you accomplish that? AFAIK PHP has no standalone GUI – just a CLI interface… – feeela Aug 02 '12 at 08:43
  • @Quentin: Exactly, and that's what this question is asking. Either that or it's badly written. It looks pretty clear from what is written that he wants to use PHP (the overwhelming majority of the time on the server) to take and save a screenshot on the clients machine. Nowhere does it state the client should have to download PHP, and run a script using ridiculous com objects to get a screenshot, etc. If your crystal ball enables you to know better than what the question is asking, feel free to improve the question. – Leigh Aug 02 '12 at 08:46
  • @feeela - we're getting off topic, since it's not what the OP wants, but a standalone GUI library for PHP can be found here: http://php-gtk.eu/ – SDC Aug 02 '12 at 08:59

2 Answers2

1

You can't do this in PHP.

You could do this using HTML5/Javascript, something like HTML2Canvas does.

Your problem with that would be compatibility with older browsers. So using this would depend on who the website is aimed at.

Nick
  • 6,316
  • 2
  • 29
  • 47
0

You have to understand one thing that PHP is a server side script and nothing to do with real time browser needs. You may try JavaScript with some library like jQuery to capture the screenshot. Then you may pass that image via AJAX and there, you can definitely use PHP to save the image into your server directory.

this stackoverflow question may help you.

Community
  • 1
  • 1
Alfred
  • 21,058
  • 61
  • 167
  • 249