解决方案 »

  1.   

    原代码测试无问题。
    检查一下文件夹权限,是不是导致fwrite失败?
      

  2.   

    有的图片无法打开提示或大或出现损坏文件的格式?检查是不是有BOM头,如果有,去掉。
      

  3.   

    readfile, 这个函数需要你的虚拟主机php.ini的设定allow_url_fopen = On 
      

  4.   

    有的图片无法打开提示或大或出现损坏文件的格式?检查是不是有BOM头,如果有,去掉。
    没有BOM头之类的:(困扰了好多天了
      

  5.   

    $pics = array(
      "http://images.wine9.com/goodsGallery/91/9187/60_90.jpg",
      "http://images.wine9.com/goodsGallery/91/9188/60_90.jpg",
      "http://images.wine9.com/goodsGallery/91/9189/60_90.jpg");foreach($pics as $k=>$fn) {
      $f = "pict/$k.jpg";
      file_put_contents($f, file_get_contents($fn));
      echo "<img src=$f>";
    }
      

  6.   

    这样更可靠$pics = array(
      "http://images.wine9.com/goodsGallery/91/9187/60_90.jpg",
      "http://images.wine9.com/goodsGallery/91/9188/60_90.jpg",
      "http://images.wine9.com/goodsGallery/91/9189/60_90.jpg");$n = 0;
    foreach($pics as $k=>$fn) {
      $f = "pict/1$k.jpg";
      while(! ($s = @file_get_contents($fn)) ) $n++;
      file_put_contents($f, $s);
      echo "<img src=$f>";
    }
    echo "多抓取 $n 次";
      

  7.   

    我也遇到过这个问题  应该也是缓存没清理的原因
    最后用这个帖子的办法解决了 推荐给你http://bbs.csdn.net/topics/320123912
      

  8.   


    $pics = array(
            "http://images.wine9.com/goodsGallery/91/9187/60_90.jpg",
            "http://images.wine9.com/goodsGallery/91/9188/60_90.jpg",
            "http://images.wine9.com/goodsGallery/91/9189/60_90.jpg"
    );foreach($pics as $key=>$value){
        $content = file_get_contents($value);
        $filename = $key.'_'.basename($value);
        file_put_contents($filename, $content, true);
        echo '<img src="'.$filename.'">';
    }