2012-10-09 45 views
2

可能重复:
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 
    } 
} 

有人看到我没有看到?非常感谢任何正确方向的提示。

+0

错误说什么? – F0G

+0

警告:当启用safe_mode或在/ home/...中设置了open_basedir时,curl_setopt():CURLOPT_FOLLOWLOCATION无法激活。但我不认为这与它有任何关系。这是我在get_file_curl()被调用时得到的警告 – Martijn

+0

@ user67510听起来像您应该关闭安全模式。 –

回答

0

在您的服务器配置中,它似乎更像是一个问题,而不是代码中的问题。

尝试在php.ini文件中禁用安全模式。

+0

安全模式关闭,open_basedir被注释掉。当我尝试一个没有空格的图像时,一切都很顺利。 – Martijn