Home > Backend Development > PHP Tutorial > 求PHP下载图片失败的解决办法

求PHP下载图片失败的解决办法

WBOY
Release: 2016-06-23 14:18:48
Original
1396 people have browsed it

PHP 图片

就以下载如下图片为例吧
  ob_start();
  readfile("http://images.wine9.com/goodsGallery/91/9187/60_90.jpg");
  $img = ob_get_contents();
  ob_end_clean();
  header("Content-type: image/jpg");
  echo $img;

回复讨论(解决方案)

1、header("Content-type: image/jpeg");
2、去掉 BOM 头

1、header("Content-type: image/jpeg");
2、去掉 BOM 头
还是不能够正常的显示:(

那就是你的问题了

<?php  ob_start();  readfile("http://images.wine9.com/goodsGallery/91/9187/60_90.jpg");  $img = ob_get_contents();  ob_end_clean();  header("Content-type: image/jpeg");  echo $img;
Copy after login
Copy after login

那就是你的问题了

<?php  ob_start();  readfile("http://images.wine9.com/goodsGallery/91/9187/60_90.jpg");  $img = ob_get_contents();  ob_end_clean();  header("Content-type: image/jpeg");  echo $img;
Copy after login
Copy after login

http://images.wine9.com/images/201110/source_img/3116_P_1319076528562.jpg若是访问这张图片就是可以的了

文件编码UTF-8 BOM保存

文件编码UTF-8 BOM保存
试过了还是不可以:(


文件编码UTF-8 BOM保存
试过了还是不可以:(
在ob_start()下面加一句ob_clean()就好了

文件编码UTF-8 BOM保存
在ob_start()下面加一句ob_clean()就好了

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template