Geodirectoty doesn't import places

This topic contains 2 replies, has 2 voices, and was last updated by  timalua 5 years, 10 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: 

  • Author
    Posts
  • #462710

    timalua
    Free User
    Post count: 40

    I go Geodirectory> import & export
    I try to import places, but I have the answer:
    “The uploaded file is not a valid CSV file. Try again.”
    I also tried to download your sample CSV, but I always have the same error.

    #462713

    Guust
    Moderator
    Post count: 29970

    Have you updated to WP 5.0.3?

    That WP bug should be fixed: https://core.trac.wordpress.org/ticket/45615

    Thanks

    #462858

    timalua
    Free User
    Post count: 40

    Thanks for your help,

    WP is version 5.0.3

    Solved by adding this code to the functions.php file.

    Andrea

    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

    <?php
    /**
    * Restore CSV upload functionality for WordPress 4.9.9 and up
    */
    add_filter(‘wp_check_filetype_and_ext’, function($values, $file, $filename, $mimes) {
    if ( extension_loaded( ‘fileinfo’ ) ) {
    // with the php-extension, a CSV file is issues type text/plain so we fix that back to
    // text/csv by trusting the file extension.
    $finfo = finfo_open( FILEINFO_MIME_TYPE );
    $real_mime = finfo_file( $finfo, $file );
    finfo_close( $finfo );
    if ( $real_mime === ‘text/plain’ && preg_match( ‘/\.(csv)$/i’, $filename ) ) {
    $values[‘ext’] = ‘csv’;
    $values[‘type’] = ‘text/csv’;
    }
    } else {
    // without the php-extension, we probably don’t have the issue at all, but just to be sure…
    if ( preg_match( ‘/\.(csv)$/i’, $filename ) ) {
    $values[‘ext’] = ‘csv’;
    $values[‘type’] = ‘text/csv’;
    }
    }
    return $values;
    }, PHP_INT_MAX, 4);

    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Viewing 3 posts - 1 through 3 (of 3 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount