• Hi. I’m trying to allow users to upload kml file type.

    Here are the details about this file type:
    https://filext.com/file-extension/KML

    I tried to set-up the functions.php file adding the following code:

    add_filter( ‘fu_allowed_mime_types’, ‘my_fu_allowed_mime_types’ );
    function my_fu_allowed_mime_types( $mime_types ) {
    // Array of 3gp mime types
    // From https://filext.com (there might be more)
    $mimes = array( ‘application/earthviewer’ );
    // Iterate through all mime types and add this specific mime to allow it
    foreach( $mimes as $mime ) {
    // Preserve the mime_type
    $orig_mime = $mime;
    // Leave only alphanumeric characters (needed for unique array key)
    preg_replace(“/[^0-9a-zA-Z ]/”, “”, $mime );
    // Workaround for unique array keys
    // If you-re going to modify it for your files
    // Don’t forget to change extension in array key
    // E.g. $mime_types[‘pdf|pdf_’ . $mime ] = $orig_mime
    $mime_types[‘kml|kml_’ . $mime ] = $orig_mime;
    }
    return $mime_types;
    }

    I’m not a programmer, so I’m sure there is something wrong or something more needed.

    Thanks for any help.
    Marco

    https://www.ads-software.com/plugins/frontend-uploader/

Viewing 1 replies (of 1 total)
  • Plugin Author Rinat

    (@rinatkhaziev)

    That looks about right. The only thing that comes to my mind is that it KML in your case has a different MIME-type.

    Try and add ‘application/vnd.google-earth.kml+xml’ to $mimes so it looks like this:

    $mimes = array( 'application/earthviewer', 'application/vnd.google-earth.kml+xml' );

    and let me know if that worked.

Viewing 1 replies (of 1 total)
  • The topic ‘Allow kml file upload’ is closed to new replies.