Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> PHP Screenshot
timez
post
Post #1





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 1.07.2016

Ostrzeżenie: (0%)
-----


Witam serdecznie, poszukuje już od kilku dni i nie mogę znaleźć.. Potrzebuję mieć zwykły przycisk który po kliknięciu będzie wyświetlać gdzie chce zapisać dany obraz /png. Znalazłem tutaj jedno ale nie działa mi niestety..
  1. function take_screenshot()
  2.  
  3. {
  4. html2canvas(document.body, {
  5. onrendered: function(canvas)
  6. {
  7. var img = canvas.toDataURL()
  8. $.post("save_screenshot.php", {data: img}, function (file){
  9. window.location.href = "save_screenshot.php?file="+ file
  10. });
  11. }
  12. });
  13. }

PHP
  1. <?php
  2.  
  3. if($_GET['file'])
  4. {
  5. $file=$_GET['file'];
  6. if (file_exists($file))
  7. {
  8. header('Content-Description: File Transfer');
  9. header('Content-Type: image/png');
  10. header('Content-Disposition: attachment; filename='.basename($file));
  11. header('Content-Transfer-Encoding: binary');
  12. header('Expires: 0');
  13. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  14. header('Pragma: public');
  15. header('Content-Length: ' . filesize($file));
  16. flush();
  17. readfile($file);
  18. unlink($file);
  19. }
  20. }
  21.  
  22. if($_POST['data'])
  23. {
  24. $data = $_POST['data'];
  25. $file = md5(uniqid()) . '.png';
  26. $uri = substr($data,strpos($data,",")+1);
  27. file_put_contents('./'.$file, base64_decode($uri));
  28. echo $file;
  29. exit();
  30. }
  31. ?>


Piszę pracę o Leap Motion, mam dane ćwiczenie które rysuje i po tym kończy się zadanie i button się wyświetla. Ale gdy go klikam niestety nic się nie dzieje a zależy mi mega by się mógł zapisać screen.. Bardzo was proszę pomoc!
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 11:15