【发布时间】:2014-09-18 02:50:28
【问题描述】:
我想使用 PHP 将图像从 url 复制到我的服务器。
我看到了这个答案Saving image from PHP URL
并尝试过:
<?php
$url = 'https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xap1/v/t1.0-1/p200x200/548412_147785902099377_260065314_n.jpg?oh=5c97dcd58931398e501666daee4c4ae8&oe=5457AC73&__gda__=1414911437_494ad1af138ee7670f89f4a6ba8b6d06';
$img = 'flower.jpg';
copy($url, $img);
?>
但我收到以下错误:
failed to open stream: No connection could be made because the target machine actively refused it.
我的 php 版本是 5.4,在我的 php.ini allow_url_fopen=On
我找不到如何解决这个问题,有什么聪明的建议吗?
【问题讨论】:
-
也许你可以使用
file_get_contents?与您链接到的问题的已接受答案一样。 -
该服务器不喜欢您尝试以这种方式访问其文件。 See this previous question - 同时,把
https中的s去掉,看看是否有帮助。 -
@CompuChip - 这与底层机制完全相同。
-
@Deryck 同样的错误仍然存在。