Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9170981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:06:04+00:00 2026-06-17T16:06:04+00:00

This is my first question on here so be nice…. I am trying to

  • 0

This is my first question on here so be nice….

I am trying to use html2canvas to ultimately get a screenshot of a remote site (user submitted url).

The problem is the cross domain security features. I cannot read from the canvas as it’s locked by off site assets.

The solution is to use the proxy feature built into the library.

There are some github projects with python and node.js versions, but I’m needing to do it in php.

There are many topics on HOW to implement the feature and how to get it working, but none really explain how to make your own proxy.

My question is two fold, are there any existing solutions in PHP? and if not, I have a few questions on making my own:
1.) What is the output format of the proxy? json object? the rendered image? the base64 encoded data string?
2.) Do these files need to persist on the server or can they just be rendered then disappear (overwritten)?

This is roughly what i’m thinking:

$img_url = urldecode($_GET['url']);
$img_data = base64_encode(file_get_contents($img_url));
//shouldn't need it since it's not cross domain now, but a CORS header could be inserted
header('content-type: application/json; charset=utf-8');
json_encode("{$_GET['callback']}($img_data)");
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:06:05+00:00Added an answer on June 17, 2026 at 4:06 pm

    I’ve found the answers to my question.
    The proxy feature accepts a jsonp element with the url to the proxied image.
    And they do need to be saved on the server while

    This is raw, I will update it later, but here is a working PHP proxy script for html2canvas

    session_start();
    //parse the url sent by the proxy function
    //TODO: scrub the input
    $img_url = urldecode($_GET['url']);
    
    //test file type
    //TODO: test for other cases that don't have a '.'
    $pos = strrpos($img_url, '.', -1);
    $ext = substr($img_url, $pos);
    
    //set a dir for this request
    function randomNumber()
    {
        return substr(sha1(rand()), 0, 15);
    }
    
    if (!isset($_COOKIE["img_path"]))
    {
        do{
            $random = randomNumber();
        }while (is_dir('images/' . $random));
    
        setcookie("img_path", $random, time()+3600);
    
    } else {
        $random = $_COOKIE["img_path"];
    }
    
    is_dir('images/' . $random) ? '' : mkdir('images/' . $random, 0755);
    
    //TODO:catch cases where a filename isn't the last element
    $basename = basename($img_url);
    
    $file = 'images/' . $random . '/' .  $basename;
    
    //save the image
    copy($img_url, $file);
    
    //TODO: don't hardcode the url
    $test_location = "http://osc.test/html2canvas2/" . $file;
    
    header('Content-Type: application/javascript');
    
    echo  "{$_GET['callback']}(" . json_encode($test_location) . ")";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my first question.. so, here we go. i have a site, 100%
first question here, be nice :P I am trying to make an infinite UIScrollView
this is my first question here so be gentle ! recently i try to
this is my first question here :) I know that I should not check
This is my first question here so try to make my best so you
Ok, I need help. This is my first question here. Background: I am working
this is my first question in here, and I would like to ask if
this is my first question on here. The question is simple - # this
this is my first time asking a question here. I tried to be well
Sorry, this's my first time to ask a question here. So, I don't have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.