php - Error in displaying the image of the screenshot of a webpage -


i've code takes screen shot of specified div tab. i'm encountering problem display .png file base64 format

here code. has 2 separate files

1) download.php

<script type="text/javascript"src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>  <script type="text/javascript" src="js/html2canvas.js"></script> <script type="text/javascript" src="js/jquery.plugin.html2canvas.js"></script> <!-- --> <div id="target"> <img src="images/1.jpg" alt="smiley face" width="100" height="100"> </div> <script type="text/javascript">     function capture() {         $('#target').html2canvas({             onrendered: function (canvas) {                 //set hidden field's value image data (base-64 string)             $('#img_val').val(canvas.todataurl("image/png"));             //submit form manually             document.getelementbyid("myform").submit();         }     }); }  </script> <input type="submit" value="take screenshot of div" onclick="return capture();" /> <form method="post" enctype="multipart/form-data" action="save.php" id="myform"> <input type="hidden" name="img_val" id="img_val" value="" /> </form> 

2)save.php

    <?php //show image $data = $_post['img_val'];  //get base-64 string data $uri = substr($data, strpos($data, ",") + 1); //decode string  $unencodeddata = base64_decode($uri); $im = str_replace($data, '+', 'img.png'); //save image $v = file_put_contents($data, $im); $result = '<img src="' . $im . '" />'; print_r($result); ?> 

i need image displayed localhost/xyz/screenshot/img.png i'm unable do.please see code me figure out problem.

thanks in advance.

i cant see element in html id attribute of target in code using it

$('#target').html2canvas({  

similar question [here][1]

i have found thing usefull

var html2obj = html2canvas($('body'));  var queue  = html2obj.parse(); var canvas = html2obj.render(queue); var img = canvas.todataurl();  window.open(img);   [1]: http://stac 

koverflow.com/questions/10457608/create-screenshot-of-webpage-using-html2canvas-unable-to-initialize-properly


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -