How to save SVG files in Wordpress from an external plugin

Viewed 79

I am creating a plugin for Wordpress in the administrative section to manage content, but I need to upload .SVG files but they are not being saved in the UPLOADS folder, I have tried many ways but none of them solves my problem:

Try this:

function custom_mtypes( $m ){
  $m['svg'] = 'image/svg+xml';
  $m['svgz'] = 'image/svg+xml';
  return $m;
}

add_filter( 'upload_mimes', 'custom_mtypes' );

Try this:

function theme_name_mime_types($mimes) {
    $mimes['svg'] = 'image/svg+xml';
    return $mimes;
}

add_filter('upload_mimes', 'theme_name_mime_types');
add_filter('mime_types',  'theme_name_mime_types');

and other options but without results, someone who can help me?

1 Answers
Related