xxxxxxxxxx
You should be able to use file_get_contents for this one. In order to use an URL with file_get_contents make sure allow_url_fopen is enabled in you php.ini file.
define('DIRECTORY', '/home/user/uploads');
$content = file_get_contents('http://anothersite/images/goods.jpg');
file_put_contents(DIRECTORY . '/image.jpg', $content);
Make sure that you have write permission to the directory where you want to store the image; to make the folder writable you could do this:
chmod +w /home/users/uploads
xxxxxxxxxx
<?php
/**
* save image from url and download
*/
$url = 'domain.com/icard452644b54af073c5.jpg';
//Create File Name with Unique Name
$Filename = uniqid('icard-').".jpg";
$img = 'icard/'.$Filename;
//Create Image File
file_put_contents($img, file_get_contents($url));
// Download File
header("Content-Type: application/force-download");
header('Content-Disposition: attachment; filename="' . basename($img) . '"');
header('Cache-Control: no-store, no-cache');
header('Content-Length: ' . filesize($img));
flush(); // Flush system output buffer
readfile($img);
// Delete From Server
unlink($img);