from.. 2020-01-17 09:42 采纳率: 100%
浏览 245

html2canvas的问题

I need to have the child image appear in a new division it places it outside the HTML tag and cuts off bottom on save any suggestions?

I was able to get Clone to work TY for that advise... But my upload is still missing app. 50 pixels from bottom of image ..... Still have not figured out how to return the image URL back and would like to get the clone to appear Directly under my generated image and not off page..... any advise on that?

          function screenshot(){
                html2canvas(document.getElementById("capture")).then(function(canvas) {   


                     var elmnt = document.getElementsByTagName("DIV")[2];
                     var cln = elmnt.cloneNode(true);
                     document.body.appendChild(cln);

                    // Get base64URL
                    var base64URL = canvas.toDataURL('image/jpg').replace('image/jpg', 'image/octet-stream');

                    // AJAX request
                    $.ajax({
                        url: 'ajaxfile.php',
                        type: 'post',
                        data: {image: base64URL},
                        success: function(data){
                            console.log('Upload successfully.');
                        }

                    });
                });
            }

Here is my ajaxfile

$image = $_POST['image'];

$location = "upload/";

$image_parts = explode(";base64,", $image);

$image_base64 = base64_decode($image_parts[1]);

date_default_timezone_set("America/Chicago");
$filename = date("m_j_y-H_i_s").'.png';

$file = $location . $filename;
$imageurl  = 'upload/'.$filename.'.png';


file_put_contents($file, $image_base64);

echo $filename;
echo $file;
echo $location;
echo $image;

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?