C
C
cloneforce2020-04-30 12:57:00
PHP
cloneforce, 2020-04-30 12:57:00

How to download a movie poster to the server?

Good afternoon.
There is this link " https://st.kp.yandex.net/images/film_iphone/iphone... "
I wanted to download images to my server, but it seems that because of the redirect it downloads an empty page.

The code:

$url = "https://st.kp.yandex.net/images/film_iphone/iphone360_1152188.jpg";
$path = 'posters/' . time() . ".jpg";

$ch = curl_init($url);
$fp = fopen($path, 'wb');
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);


thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stimulate, 2020-04-30
@cloneforce

$url = "https://st.kp.yandex.net/images/film_iphone/iphone360_1152188.jpg";
$path = 'posters/' . time() . ".jpg";

$ch = curl_init($url);
$fp = fopen($path, 'wb');
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
curl_close($ch);
fclose($fp);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question