【发布时间】:2017-09-02 21:24:06
【问题描述】:
我有一个 WordPress 网站,我们在使用图片时遇到了一些问题。
图片存在于服务器上,当我们通过 URL 访问图片时,它可以工作并显示图片。
但是当我们使用 curl、file_get_contents、fopen、copy 等命令获取或访问文件时,会得到 404 错误状态码。
谁能帮帮我,我不知道这是服务器问题还是WordPress问题。
下面是我的代码示例:
$url = "http://blogbucket.in/wp-content/uploads/files/0B6IGyYw9A5RYS0tNelJrdmFsMTQ/airbitz-co1.png";
$ch = @curl_init($url);
@curl_setopt($ch, CURLOPT_HEADER, true);
@curl_setopt($ch, CURLOPT_NOBODY, true);
@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
@curl_setopt($ch, CURLOPT_FAILONERROR, true);
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
@curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
@curl_exec($ch);
$header = curl_getinfo($ch);
curl_close($ch);
echo "<pre>";
print_r($header);
echo "<pre>";
以下是我目前看过的链接。
cURL is returning 404 on a file that exists (remote server). Why?
How to check if an URL exists with the shell and probably curl?
PHP Detecting if source image url link leads to a "broken" image?
你可以试试here。
【问题讨论】:
-
我们需要查看您的代码,使用 PHP Curl 制作一个示例并将其发布,以便我们了解您正在尝试做什么
-
@zack6849 当然,我会更新我的问题。
-
你们为什么要降级我的问题,如果你认为自己擅长,那就解决这个问题。
标签: php curl url-rewriting server http-status-code-404