应该这样请注意中间部分<?php $filename="http://gameimage.egchina.com/shamu/shenmue-ad-02.jpg";
$outputname="1234.jpg";
$fp=fopen($filename,"rb");
$contents = '';
do
{
$data = fread($fp,8192);
if ( strlen($data) == 0 )
break;
else
$contents .= $data;
}while(true);
fclose($fp);
$handle=fopen($outputname,"wb");
fwrite($handle,$contents);
fclose($handle);?>

解决方案 »

  1.   

    由于图片是2进制文件,因此读取其内容时需要用rb参数而不是r。
      

  2.   

    请问一下unixdotnet(concinnity)兄
    那个8192为什么要用这个数字?
      

  3.   

    $filename="http://gameimage.egchina.com/shamu/shenmue-ad-02.jpg";
    $outputname="1234.jpg";$fp=fopen($filename,"rb");
    $contents = fread ($fp, filesize($filename));
    fclose($fp);$handle=fopen($outputname,"wb");
    fwrite($handle,$contents);
    fclose($handle);打开文件时,win32系统必须要有“b”参数
      

  4.   

    filesize()本函数不能作用于远程文件,被检查的文件必须通过服务器的文件系统访问。
      

  5.   

    呵呵!什么时候改成那样的啦?我可是一直都这样用的!那么更简单的写法:
    $filename="http://gameimage.egchina.com/shamu/shenmue-ad-02.jpg";
    $outputname="1234.jpg";$contents = file_get_contents($filename); //php ver>=4.3.0// file_put_contents($outputname,$contents); //php ver=5$handle=fopen($outputname,"wb");
    fwrite($handle,$contents);
    fclose($handle);