WordPress.org

Ready to get started?Download WordPress

Forums

WP Ultimate CSV Importer Plugin
[resolved] Plugin fails to download the image if it contains spaces in filename (14 posts)

  1. shark0der
    Member
    Posted 1 year ago #

    The copy function throws an error if the image URL contains spaces in it. For example: http://www.domain.com/path/to/file name.png

    I fixed this for myself by replacing spaces with '%20' in csv file but this is rather a workaround then a fix.

    UPDATE: the just mentioned fix doesn't work as it downloads the images but they are not displayed correctly in posts. Proper URL handling needed.

    http://wordpress.org/extend/plugins/wp-ultimate-csv-importer/

  2. shark0der
    Member
    Posted 1 year ago #

    Here's a quick fix:

    $dir = wp_upload_dir();
    $dirname = 'featured_image';
    $full_path = $dir['basedir'].'/'.$dirname;
    $baseurl = $dir['baseurl'].'/'.$dirname;
    $filename = explode('/',$file_url);
    $file_split = count($filename);
    $nofun_allowed = preg_replace('/[^a-z0-9._-]/', '-', $filename[$file_split-1]);
    $filepath = $full_path.'/'.$nofun_allowed;
    $fileurl = $baseurl.'/'.$nofun_allowed;
    if(is_dir($full_path)){
        $smack_fileCopy = copy($file_url,$filepath);
    }

    I use preg_replace because it's easier then url-encode/decode and the original filename is not really needed.

  3. shark0der
    Member
    Posted 1 year ago #

    I fixed 3 issues in this plugin, now you can buy me a beer :)

  4. cozyclosets
    Member
    Posted 1 year ago #

    I am pulling my hair out with this. 10000 products no images do you have the csv your using. Help would be greatly appreciated and I will buy u a beer

  5. cozyclosets
    Member
    Posted 1 year ago #

    I tried your code but filename and type in featured_image folder are just dashes ---------------------------------- Not sure about that

  6. shark0der
    Member
    Posted 1 year ago #

    Here's a copy of what I've come up to: http://ge.tt/37jlxed/v/0?c

    Your filenames probably contain [only] non-ascii characters (like Chinese or something) and what I basically do is to replace all non-alphanum with dashes to there are no spaces or other characters that need to be converted to %20 (or the corresponding hex representation).

    An additional improvement that would be also needed is to add a timestamp to the filenames. It's needed because the plugin doesn't check the uniqueness of the filename right now and by uploading an image with the same filename it would get overwritten.

  7. cozyclosets
    Member
    Posted 1 year ago #

    Can you send me a .csv file that you are using so I can see how you constructed it. Thanks in advance

  8. shark0der
    Member
    Posted 1 year ago #

  9. cozyclosets
    Member
    Posted 1 year ago #

    wp-content/uploads/featured_image/----.JPG this is what I get when its imported?

  10. shark0der
    Member
    Posted 1 year ago #

    what's the original url/filename that you're trying to upload?

  11. cozyclosets
    Member
    Posted 1 year ago #

    ABUD.JPG

  12. cozyclosets
    Member
    Posted 1 year ago #

  13. shark0der
    Member
    Posted 1 year ago #

    The filename seems to be OK, I don't know what's the cause of your problem. Sorry :-/

  14. smackcoders
    Member
    Plugin Author

    Posted 1 year ago #

    New version is released with improvements and fixes. Please upgrade and leave your feedback. Hope it works well as expected.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic