• Resolved chcw

    (@chcw)


    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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hey @chcw,
    The code you’ve written should allow the upload of .wma files by adding the correct MIME type. However, some WordPress configurations, web hosts, or even certain server security settings (like Apache or Nginx) may block certain file types from being uploaded regardless of the MIME type being allowed.

    1. Ensure that the MIME type you’ve set for .wma is correct. Instead of 'audio/x-ms-wma', try 'audio/wma' as well to see if this resolves the issue.
    2. Try to check if your host has .wma extension, and if it has been enabled.
    3. Some security plugins can disable this if you have them, if the two methods above do not work, try to disable some security plugins, if any.

    Hope this helps!

    Thread Starter chcw

    (@chcw)

    Hi, @manuell

    1. ‘audio/wma’ also not work.
    2. How to check? Is there any document available?

    Thank you

    That will depend with your host.

    threadi

    (@threadi)

    Check the file you are using with this tool: https://www.htmlstrip.com/mime-file-type-checker – you may get a completely different mimetype.

    Also try it with a different browser. Some set their own mimetypes for their own files depending on the tools installed. These are then reported to the server during the upload, which may also trigger incorrect recognition.

    Thread Starter chcw

    (@chcw)

    The correct mime type is:

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.