可能重复:
CURLOPT_FOLLOWLOCATION cannot be activated文件名空间? file_put_contents
我使用的是WordPress插件在我的WordPress网站上传了一系列图像。它总是工作正常,除非图像网址中有空格。 我试过使用urlencode,但我仍然收到错误。这是它打破了代码:
当我echo
出$img
它
"http://omodaimg.xcdn.nl/RM1000,1000/taupe-paul-green-sneakers-1157/PAUL GREEN/31024_1.png"
不带引号。
foreach ($imgs as $img) {
$image_filename = wp_unique_filename($uploads['path'], basename(parse_url(trim($img), PHP_URL_PATH)));
$image_filepath = $uploads['path'] . '/' . $this->url_title($image_filename);
if (! file_put_contents($image_filepath, @file_get_contents(trim($img)))) {
if (! get_file_curl(trim($img), $image_filepath)) {
$logger and call_user_func($logger, sprintf(__('<b>ERROR</b>: File %s cannot be saved locally as %s', 'pmxi_plugin'), trim($img), $image_filepath));
unlink($image_filepath); // delete file since failed upload may result in empty file created
}
}
有人看到我没有看到?非常感谢任何正确方向的提示。
错误说什么? – F0G
警告:当启用safe_mode或在/ home/...中设置了open_basedir时,curl_setopt():CURLOPT_FOLLOWLOCATION无法激活。但我不认为这与它有任何关系。这是我在get_file_curl()被调用时得到的警告 – Martijn
@ user67510听起来像您应该关闭安全模式。 –