file_get_contents jpg损坏下载

I am downloading this photo using function: file_get_contents(), and it seems to be corrupted. But original photo looks fine.

Original photo: original photo

Downloaded photo: Download photo

Code:

$current = file_get_contents($image);
$name = '/tmp/img/' . uniqid().".jpg";
file_put_contents($name, $current);
$tmpImages[] = $name;

Try this.

function savephoto($urlpath,$savepath)
{ //Download images from url
    $in =    fopen($urlpath, "rb");
    $out =   fopen($savepath, "wb");
    while ($chunk = fread($in,8192))
    {
        fwrite($out, $chunk, 8192);
    }
    fclose($in);
    fclose($out);
}

savephoto('http://i.stack.imgur.com/pwMiA.jpg','newname.jpg');