phpwordpressmime-types

Cannot upload WMA files in WordPress plugin


I try to upload a .wma file in WordPress plugin, but get the error "This file type is not allowed"

But I have already added the support to .wma file type as below:

   // Add this filter to allow mime file uploads
   add_filter('upload_mimes', array($this, 'allow_mime_uploads')); 

    public function allow_mime_uploads($mimes) {
        $mimes['epub'] = 'application/epub+zip';
        $mimes['djvu'] = 'image/vnd.djvu';
        $mimes['jfif'] = 'image/jpeg';
        $mimes['htm'] = 'text/html';
        $mimes['html'] = 'text/html';
        $mimes['svg'] = 'image/svg+xml';
        $mimes['eps'] = 'application/postscript';
                $mimes['psd'] = 'image/vnd.adobe.photoshop';
                $mimes['mobi'] = 'application/x-mobipocket-ebook';
                $mimes['vob'] = 'video/dvd';
                $mimes['dwg'] = 'image/vnd.dwg';
                $mimes['wma'] = 'audio/x-ms-wma';
                
        return $mimes;
    }  

The other file types, such as .dwg can be uploaded after adding the mime type, but .wma does not work.


Solution

  • Here is the solution use it in the code, I checked. It is working.

    $mimes['wma'] = 'video/x-ms-asf';