Curl을 사용하여 URL에 이미지를 업로드하고 싶습니다. 그러나 이미지 파일이 https url에 있으므로 fopen을 사용하여 파일을 읽을 수 없습니다.PHP : CURL PUT FOR Https fopen으로 작동하지 않는 URL이 없습니다.
코드는 다음과 같습니다.
$file = "https://xyz.com/image.jpg";
$url = "http://abc.com/upload.php";
$fp = fopen($file, "r");
$headers = array("Content-Type: xml");
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
$responseInfo = curl_getinfo($ch);
curl_close($ch);
나를 보자. 내 마법의 수정 구슬이 우리에게 새로운 달이 있다고 말하면서 코드가 작동하지 않는 이유입니다. 진심으로, 귀하의 질문에 표시되는 오류 메시지를 추가하십시오. –