Viewing 7 replies - 1 through 7 (of 7 total)
  • I ran into this problem as well, and for me it was a problem with having spaces in the URL I was trying to get (it looks like you probably have the same problem).
    There is an open ticket about this:
    https://core.trac.www.ads-software.com/ticket/16330

    As a desperate quick fix, I wound up changing my wp-admin/includes/file.php to change spaces into “%20″s — though changing core files is a really bad idea! (I needed a solution Right Now, and I will be keeping track of the changes, as well as the ticket to see if it gets resolved.)

    This also happens if the dropbox folder you are sideloading from has spaces.

    “To Sideload” failed as above.

    “ToSideload” did not.

    It seems like it’s NOT getting solved at this point.
    Morgan, you made a change to the file.php which changed spaces to “%20”.
    Where, and how, would that be made exactly?

    Thanks in advance.

    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>

    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!

    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. ??

    Not RegeX familiar enough to contribute, but isn’t there a filter for directly exchanging these codes for their ascii equiv? Ge gentle.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘error when sideloading’ is closed to new replies.