0

How can I make a PHP page that will return image from other server specified by url in variable, like this:

http://www.mypage.com/MyScript.php?src=http://www.otherpage.com/image.png

And after going to that page an image should apear.

It need to work for any other srcs too.

(Why like this? I want to try bypass the Security Error that apears using toDataUrl from canvas while using image not from the same domain, by using http://www.mypage.com/MyScript.php?src=http://www.otherpage.com/image.png as a image src used in canvas)

Kyrtap
  • 158
  • 1
  • 1
  • 8

2 Answers2

0

In MyScript.php, use $_GET['src'] as the source of the image

<img src="<? echo $_GET['src']; ?>" />
RMK
  • 456
  • 2
  • 9
  • 19
0

You can try with

echo file_get_contents($_GET['src']);
Sergio Terrasi
  • 457
  • 4
  • 6
  • as long as the fopen wrappers are enabled. –  Nov 10 '13 at 19:03
  • Using any img url shows error: Warning: file_get_contents() [function.file-get-contents]: Filename cannot be empty in /xxxx/xxxx/public_html/xxxx/Myscript.php on line 2 (line 2 is this code) – Kyrtap Nov 10 '13 at 19:06
  • $_GET['src'] is empty, IMHO. Try print_r($_GET['src']) to check if it's empty or not. Or try echo file_get_contents('http://URL/TO/IMAGE.png') and test if file_get_contents works. – Sergio Terrasi Nov 10 '13 at 20:28