Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Seems the issue is really a WP core problem with media_sideload_image(). preg_replace() between “\” and “.” from right to left. before calling media_sideload_image(). That would have been my next thought. But then I could have my head in a dark place. ??

    oops ! forgot one little wrinkle – if you don’t change this line your file will have the %20 where the spaces where in file name saved on the server. so do this –
    replace:
    $file_array[‘name’] = basename($matches[0]);

    with:
    $file_array[‘name’] = preg_replace(‘/\s|%20/’, ‘-‘, basename($matches[0]));
    in file
    wp-admin/includes/media.php
    ok its a core file but it works your file gets uploaded and gets saved as something you can use.

    You would think sideload function would sanitize the file names – oh well!

    Try this it works just fine, around line 214 in file dropbox-photo-sideloader.php in wp-content/plugins/dropbox-photo-sideloader

    replace:

    $result = media_sideload_image(urldecode($tempurl[‘url’]), $post_id);

    with:

    $result = media_sideload_image(urldecode(rawurlencode($tempurl['url'])), $post_id);

    I also added:

    $file = rawurlencode($file);
    above:
    			echo "
    <li>Sideloading {$file} ... ";
    just for an intelligent check
    works current wp version as of this post.
    Merry Christmas</li>
Viewing 3 replies - 1 through 3 (of 3 total)