function grab_image($url, $saveto){
$ch = curl_init ($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$raw = curl_exec($ch);
curl_close($ch);
if (file_exists($saveto)){
unlink($saveto);
}
$fp = fopen($saveto, 'x');
fwrite($fp, $raw);
fclose($fp);
}
$file = file_get_contents('images.txt');
$images = explode("\n", $file);
$i = 0;
foreach ($images as $image) {
$i++;
echo "image number: " .$i. "<br>";
$fileName = explode('/', $image);
end($fileName);
$key = key($fileName);
$fp = 'images/'.$fileName[$key];
grab_image(str_replace(" ","%20", $image), $fp);
}
Вот, так же может Вы это ищите: https://mdbootstrap.com/docs/jquery/components/spi...