-1

I have a form in page1.php where a users selects the products and then the page is redirected to page2.php where he gets his table to update based on his selection.Have used FORM VARIABLES. And now what i want is that when the user clicks the update button on page2.php a full page screenshot should be captured and sent directly to MYSQL DATABASE. MY database name = test my table = test_table and I even have made the image column BLOB in my database.

What I need is that I want the images directly to be sent from page2.php and return to page1.php.

Pupil
  • 23,834
  • 6
  • 44
  • 66
  • 4
    wait, first of all answer this question: WHY do you need page screenshots? – STT LCU Oct 02 '13 at 09:11
  • 2
    A good practice is: Save only the image path to database, not the image data. – Raptor Oct 02 '13 at 09:11
  • and how do i do it mr.Shivan Raptor – user2837930 Oct 02 '13 at 09:12
  • This isn't very easy - you can't make the OS take a screenshot, so you need to instead render the html+css+js you sent them to a bitmap. http://html2canvas.hertzen.com/ lets you do this, but it's pretty experimental – not many people do this because it's hard. – Rich Bradshaw Oct 02 '13 at 09:14
  • like i want to preserve it . so that i can no after each update a user makes. can be compared in the images... – user2837930 Oct 02 '13 at 09:15
  • 1
    It's question about "I want to spy on what users are doing here" – baldrs Oct 02 '13 at 09:15
  • the main purpose is that. i should know that whenever a user makes an update in in the table. – user2837930 Oct 02 '13 at 09:16
  • Can't you just log the changes the user made? Presumably you know what the table looked like to start with, so if you log the changes they make you can re-create the image at any stage later. – Clart Tent Oct 02 '13 at 09:21
  • ah, another XY problem... You want to log the user updates! well, taking a screenshot is very creative, lol – STT LCU Oct 02 '13 at 10:06

2 Answers2

0

You cannot use Javascript/PHP to take an actual screen shot in the same way a user would using the screenshot functionality of their operating system.

Your only real option would be to use HTML2Canvas to generate an image using the HTML on the users page.

Please see this answer for details: https://stackoverflow.com/a/15597205/2598779

Community
  • 1
  • 1
Mike Hancock
  • 230
  • 2
  • 8
0

Actually there is a php function called imagegrabscreen. To save it as an .png image, try this:

<?php
    $im = imagegrabscreen();
    imagepng($im, "myscreenshot.png");
    imagedestroy($im);
?>

Note: This will only work in Windows.

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


If you want to grab the window, so a printscreen of the browser window, use imagegrabwindow:

<?php
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Navigate("http://www.example.com");

/* Still working? */
while ($browser->Busy) {
    com_message_pump(4000);
}
$im = imagegrabwindow($handle, 0);
$browser->Quit();
imagepng($im, "iesnap.png");
imagedestroy($im);
?>

Note: This will only work in Windows too and has been written for Internet Explorer.

http://www.php.net/manual/en/function.imagegrabwindow.php

Joran Den Houting
  • 3,149
  • 3
  • 21
  • 51