2

Possible Duplicate:
CURLOPT_FOLLOWLOCATION cannot be activated

I am using a WordPress plugin on my WordPress site to upload a series of images. It always works fine, unless the image urls got spaces in them. I tried using urlencode but I am still getting errors. This is the code where it breaks:

When I echo out $img it's

"http://omodaimg.xcdn.nl/RM1000,1000/taupe-paul-green-sneakers-1157/PAUL GREEN/31024_1.png"

without the quotes.

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
    }
} 

Is anyone seeing with I am not seeing? Any hints in the right direction are very much appreciated.

Community
  • 1
  • 1
Martijn
  • 373
  • 1
  • 4
  • 15
  • Warning: curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in /home/.... But I don't believe that got anything to do with it. This is the warning I get when get_file_curl() is called – Martijn Oct 09 '12 at 12:45
  • @user67510 sounds like you should turn safe mode off.. – Explosion Pills Oct 09 '12 at 12:46
  • If you don't want to turn off safe mode then this may help: http://stackoverflow.com/questions/223800/how-can-i-relax-phps-open-basedir-restriction – loler Oct 09 '12 at 12:49
  • Safe mode is off and open_basedir is commented out. I am on my own VPS by the way. – Martijn Oct 09 '12 at 12:58
  • Also the function get_file_curl() is using the solution posted in http://stackoverflow.com/questions/6352927/curlopt-followlocation-cannot-be-activated – Martijn Oct 09 '12 at 12:59

1 Answers1

0

It seems to be more of a problem in your server configuration rather than problem in your code.

Try disabling safe mode in your php.ini file.

Sudar
  • 18,954
  • 30
  • 85
  • 131
  • Safe mode is off and open_basedir is commented out. When I try a image without spaces in it, everything goes fine. – Martijn Oct 09 '12 at 13:50