$url = 'http://www.example.com/images/image.jpg'; $img = 'files/random_new_image_name.jpg'; file_put_contents($img, file_get_contents($url));