duanlun4411 2016-12-19 10:43
浏览 134

包括imagegrabscreen php功能到按钮onclick而不刷新页面

I'm trying to create a button with an onclick function that activates the imggrabscreen php function. Problem is, I've done several codes and so far the only function that I was able to use was a submit input type in which this refreshes the page. I tried using button as an input type but unfortunately, it does not save any screenshots upon clicking the button. Here's the code that I'm using so far.

if(isset($_POST['btnscreen']))
{

    $im = imagegrabscreen();
    imagepng($im, "screenshot.png");
}
ob_end_flush();
?>

<form method="post" action="" enctype="multipart/form-data"> 
    <br>
    <input type="submit" value="Click to Screenshot" id="btnscreen" name="btnscreen"></center>
    <br><br>
</form>

</div>
  • 写回答

1条回答 默认 最新

  • duanhan3067 2016-12-19 15:30
    关注

    php is parsed and executed server side (pre-processing) so you cannot call any php functions after the page has been sent to the browser. The only way to do this is to make a new request to the server (ajax).

    I can't quite grasp what your function does (php cannot make a screenshot of what your browser is displaying as it has no information of how it has been rendered - please note different browsers may display the page differently).

    I would try reading up on html5 canvas element which can achieve that (e.g. https://html2canvas.hertzen.com/).

    Hope this helps

    评论

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀