D
D
Dmitry Pacification2017-03-31 10:22:54
PHP
Dmitry Pacification, 2017-03-31 10:22:54

How to optimize a curl request to download a lot of pictures in 1 connection?

$images = [' https://hostname/image-1.jpg ', ' https://hostname/image-2.jpg ', ... ' https://hostname/image-1800.jpg '];
$ch = curl_init($images[0]);
$fp = fopen("./images/{$i}", 'wb'); // save the image to my server
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2017-03-31
@dmitry_pacification

Read about curl_multi

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question