brcontainer / html2canvas-php-proxy

PHP Proxy html2canvas
MIT License
134 stars 77 forks source link

Demo not working #6

Closed MickCoelho closed 10 years ago

MickCoelho commented 10 years ago

Unfortunately it seems like the demo isn't working anymore.

brcontainer commented 10 years ago

What is the error that the console shows?

MickCoelho commented 10 years ago

Absolutely nothing. I literally copied your files and try to run them from a server, but it doesn't return the image.

brcontainer commented 10 years ago

I tried and work fine. Try this:

                html2canvas(document.body, {
                    "logging": true,//Enable log
                    "proxy":"html2canvasproxy.php",
                    "onrendered": function(canvas) {
                        var uridata = canvas.toDataURL("image/png");
                        window.open(uridata);
                    }
                });

See test-case download: http://www.mediafire.com/download/52rtkcqccd1yiw5/test-case2.rar

If you still do not succeed, try accessing the link, something like: http://site.com/location_folder/html2canvasproxy.php?url=http%3A%2F%2Fmaps.googleapis.com%2Fmaps%2Fapi%2Fstaticmap%3Fcenter%3D40.714728%2C-73.998672%26zoom%3D12%26size%3D800x600%26maptype%3Droadmap%26sensor%3Dfalse%261&callback=html2canvas_0

[update] Get errors in Firefox Console: https://developer.mozilla.org/en-US/docs/Tools/Browser_Console Get errors in Chrome Console: https://developers.google.com/chrome-developer-tools/docs/console

MickCoelho commented 10 years ago

It works on another FTP. Seems like it's link to the Apache security. All good!

brcontainer commented 10 years ago

Could you be more clear about the problem?

MickCoelho commented 10 years ago

All the files where in a password protected (using .htaccess) folder, I guess that was the reason why it wasn't working. On another FTP server it works like a charm.

brcontainer commented 10 years ago

[update] I understand, as you do not have to add another. ".htaccess" inside the images folder (which is generated in the same directory html2canvasproxy.php) for this new ".htaccess" no longer requires password on "images" folder?

In a folders structure like this:

/www/project-1/
/www/project-1/.htaccess
/www/project-1/index.php
/www/project-1/javascript/
/www/project-1/javascript/html2canvas.js
/www/project-1/apis/
/www/project-1/apis/html2canvasproxy.php

Create an folder (if no exists) in /www/project-1/apis/ with named images, add in this folder a new file width name .htaccess.

Add in new .htaccess this: Satisfy Any

The folder structure should look something like this:

/www/project-1/
/www/project-1/.htaccess
/www/project-1/index.php
/www/project-1/javascript/
/www/project-1/javascript/html2canvas.js
/www/project-1/apis/
/www/project-1/apis/html2canvasproxy.php
/www/project-1/apis/images/
/www/project-1/apis/images/.htaccess
MickCoelho commented 10 years ago

Thank you, very helpful! Will have a deeper look into it soon.

brcontainer commented 10 years ago

Welcome!