Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • @killua99 I think that problem not in WP Core, but in fileinfo PHP extension.

    Do you think that we need to modify WP Core to fix this?

    Hi everyone!

    There is another one cause and a solution for it.
    Using define(‘ALLOW_UNFILTERED_UPLOADS’, true); isn’t a good practice so we need to look deeper.

    I’ve found out that, in some cases, php extension fileinfo works not good enough and cannot determine MIME of csv files properly.

    In that case I use next recipe:
    1. Go to wordpress/wp-includes/functions.php
    2. Find finfo_open( FILEINFO_MIME_TYPE );
    3. Enrich it with a path to a magic database (details) and get something like $finfo = finfo_open( FILEINFO_MIME_TYPE, '/usr/share/misc/magic' );
    4. Add if block if ( false === $real_mime ) $real_mime = 'text/plain'; after finfo_close( $finfo );

    This solution works only if php extension on your hosting works improperly.
    If you have another cause of issue, it won’t work

    And also because it is a core hack you need to add it again after each update.

Viewing 2 replies - 1 through 2 (of 2 total)