Answer the question
In order to leave comments, you need to log in
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);
Answer the question
In order to leave comments, you need to log in
$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 questionAsk a Question
731 491 924 answers to any question