Php AmazonS3通过公共URL下载图像文件

Php AmazonS3通过公共URL下载图像文件,php,image,url,amazon-s3,amazon,Php,Image,Url,Amazon S3,Amazon,我已在此位置使用Amazon S3服务上载了我的图像“” 上传后,我得到的回应如下 我试图通过下面的方法获得形象,但没有成功 (1)................ $xman = explode("/",$ImageSTR); //$saveto = end($xman).'.jpg'; $saveto = end($xman); $fl = file_get_contents($ImageSTR); file_put_contents('abcd.j

我已在此位置使用Amazon S3服务上载了我的图像“” 上传后,我得到的回应如下

我试图通过下面的方法获得形象,但没有成功

(1)................
    $xman = explode("/",$ImageSTR);
    //$saveto = end($xman).'.jpg';
    $saveto = end($xman);
    $fl = file_get_contents($ImageSTR);
    file_put_contents('abcd.jpg',$fl);

(2)................
    grab_image($ImageSTR,$saveto);  

    function grab_image($url,$saveto){
        $ch = curl_init ($url);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
        $raw=curl_exec($ch);
        curl_close ($ch);
        if(file_exists($saveto)){
            unlink($saveto);
        }
        $fp = fopen($saveto,'x');
        fwrite($fp, $raw);
        fclose($fp);
    }

提前感谢您

您可以看到这是https,您需要像这样使用CURLOPT_SSL_VERIFYPEER

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
这是最后一个函数

function grab_image($url,$saveto){
    $ch = curl_init ($url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    $raw=curl_exec($ch);
    curl_close ($ch);
    if(file_exists($saveto)){
        unlink($saveto);
    }
    $fp = fopen($saveto,'x');
    fwrite($fp, $raw);
    fclose($fp);
}
你可以在这里阅读更多信息

希望这有帮助