Allow kml file upload
-
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/KMLI 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
- The topic ‘Allow kml file upload’ is closed to new replies.