如何通过PHP中的URL获取图像的内容?

I am using an api of a SNS website, which is uploading an image. This api has a parameter "photo=photo_file_content", and is basing on RFC 1867.

Now I have the url of a certain image, but I don't kwon how to fetch the image, I've used $param['photo'] = file_get_contents($pic_path); , but it didnt' work.

So what's the proper way to get the image? Thanks.

You can use Client URL Library. It is the best solution for you.

Also, try this:

$ch = curl_init ($url);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
        $gm=curl_exec($ch);
        curl_close ($ch);

and save the result $gm in a file.