2

I already find answers how to copy images over HTTP, but when I try to copy images over HTTPS then I get this:

Warning: copy(): SSL operation failed with code 1. OpenSSL Error messages: error:14077458:SSL routines:SSL23_GET_SERVER_HELLO:reason(1112)

This is code I use:

copy('https://www.metalacmarket.com/product-img/org/JpUSP3KgvgeeikNheRDi4CRg.jpg', IMAGES_PATH.'JpUSP3KgvgeeikNheRDi4CRg.jpg');

Any idea how to get images over HTTPS?

gSorry
  • 1,254
  • 2
  • 21
  • 29

1 Answers1

2

You could use cURL.

Here's an example adapted from the basic curl example.

$source = 'https://www.metalacmarket.com/product-img/org/JpUSP3KgvgeeikNheRDi4CRg.jpg';
$target = 'image.jpg';

$ch = curl_init($source);
$fp = fopen($target, "wb");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);
Pj Dietz
  • 921
  • 9
  • 16
  • Good idea, but now I get this error: error:14077458:SSL routines:SSL23_GET_SERVER_HELLO:reason(1112) – gSorry Oct 05 '13 at 07:37
  • 1
    You be able to get this to work by setting some cURL options. Check out this question: [PHP Curl: SSL routines:SSL23_GET_SERVER_HELLO:reason(1112)](http://stackoverflow.com/questions/18191672/php-curl-ssl-routinesssl23-get-server-helloreason1112) – Pj Dietz Oct 09 '13 at 13:30