1

I'm generating image with html2canvas and I want to save it on server. When I try to do that I get error 413 Request entity too large in console and image is not saved. Everything works on localhost but not on live server.

I have googled how to solve this problem for 2 days already, my php.ini and .htaccess are configured correctly so I'm pretty sure thats not the problem.

HTML:

<button onclick="fb()">Save</button>

JavaScript:

    <script language="javascript">
  function fb(){
    var w= <?php echo $resolution['width'] ;?>;
    var h= <?php echo $resolution['height'] ;?>;
     $("#picture").show();
html2canvas($('#picture'), {
width: w,
height: h
}).then(function(canvas) {
  var imgData = canvas.toDataURL('image/png');   



    var url = 'export.php';
        $.ajax({ 
            type: "POST", 
            url: url,
            dataType: 'text',
            data: {
                base64data : imgData,
            } 
}); 
})}
</script>

PHP:

    <?php

    $data = $_REQUEST['base64data']; 
    $image = explode('base64,',$data); 

    file_put_contents('../public/image/myImage.png', base64_decode($image[1]));

?>

0 Answers0