求解决一个php下载图片失败的问题,图片必须能全部正常显示 PHP图片 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 原代码测试无问题。检查一下文件夹权限,是不是导致fwrite失败? 有的图片无法打开提示或大或出现损坏文件的格式?检查是不是有BOM头,如果有,去掉。 readfile, 这个函数需要你的虚拟主机php.ini的设定allow_url_fopen = On 有的图片无法打开提示或大或出现损坏文件的格式?检查是不是有BOM头,如果有,去掉。没有BOM头之类的:(困扰了好多天了 $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>";} 这样更可靠$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 次"; 我也遇到过这个问题 应该也是缓存没清理的原因最后用这个帖子的办法解决了 推荐给你http://bbs.csdn.net/topics/320123912 $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.'">';} 生成的图片验证码不能显示中文 PHP发送邮件问题 php 5.1.4 安装pear后为什么没有DB.php Call to undefined function OCIplogon() [济南]招聘PHP开发人员,希望版主手下留情 JS的小问题,大家进来看看 有用过mb_convert_encoding函数的吗?我将utf-8转换为gbk的时候,空格变成了??? 如何把一个数组里所有的空行去掉? 欲高价购买一套类似碧聊的语音聊天程序. UP者有分! 送分!哪里的虚拟主机比较好? apache和PHP关联不起来 求个正则表达式!!!!!!!
检查一下文件夹权限,是不是导致fwrite失败?
没有BOM头之类的:(困扰了好多天了
"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>";
}
"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 次";
最后用这个帖子的办法解决了 推荐给你http://bbs.csdn.net/topics/320123912
$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.'">';
}