WordPress.org

Support

Support » Plugins and Hacks » Frontend Uploader » [Resolved] [bug] Allowed mime types are blocked by Frontend Uploader

[Resolved] [bug] Allowed mime types are blocked by Frontend Uploader

  • When the plugin is activated new mime types cannot be added to the wordpress core (functions.php). This code clashes with your mime type checking. When you add this code to the functions.php :

    add_filter('upload_mimes', 'custom_upload_mimes');
     function custom_upload_mimes ( $existing_mimes = array() ) {
     // add your extension to the array
     $existing_mimes['psd'] = 'application/photoshop';
     unset( $existing_mimes['exe'] );
    
     return $existing_mimes;
     }

    And the plugin is activated, wordpress will not allow uploads of this mime types.

    http://wordpress.org/extend/plugins/frontend-uploader/

Viewing 15 replies - 1 through 15 (of 15 total)
  • When i add just your code:

    add_filter( 'fu_allowed_mime_types', 'my_fu_allowed_mime_types' );
    function my_fu_allowed_mime_types( $mime_types ) {
        $mime_types['psd'] = 'image/photoshop';
    	$mime_types['epub'] = 'application/xhtml+xml';
    	$mime_types['mobi'] = 'application/xhtml+xml';
    	$mime_types['fb2'] = 'text/fb2+xml';
        return $mime_types;
    }

    Then wordpress will also block the mime types.

    Now that i am on the topic. I saw another upload plugin (inline Uploader). With this plugin you could add new mime types using the shortcode. That was very easy. But i also like that your plugin will use the default mime types of the wordpress core.

    Example

    [inline_upload uploadrole="all" uploadpath="/uploads/visitors/" createpath="false" uploadpatterns="\*.mp3,\*.mp4

    Plugin Author Rinat Khaziev

    @rinatkhaziev

    This is weird. It shouldn’t interfere with WP mime-types. Can you post detailed step-by-step guide on how to reproduce the issue?

    The Steps:

    Install fresh WP
    Upload .psd file -> is not allowed
    Add code to functions.php

    // Add new file extensions to list of allowable file types
    add_filter('upload_mimes', 'custom_upload_mimes');
    function custom_upload_mimes ( $existing_mimes = array() ) {
     // add your extension to the array
     $existing_mimes['psd'] = 'application/photoshop';
    return $existing_mimes;
     }

    Upload .psd is allowed
    Upload and Activate your plugin
    Upload .psd file -> Not allowed anymore

    You can check it for yourself.

    Plugin Author Rinat Khaziev

    @rinatkhaziev

    I will check it. In the mean time, try to use

    add_filter( 'fu_allowed_mime_types', 'my_fu_allowed_mime_types' );
    function my_fu_allowed_mime_types( $mime_types ) {
        $mime_types['psd'] = 'application/photoshop';
        return $mime_types;
    }

    I tried to use that. But i still get an error :

    “header-980.psd” has failed to upload due to an error
    Sorry, this file type is not permitted for security reasons.

    I installed the plugin on another different server and the same problem appears.

    Plugin Author Rinat Khaziev

    @rinatkhaziev

    Thanks uddhava,

    I was able to specify the bug, it will be fixed in the next release.

    Thats wonderful. any beta realease that i can test? (with progress bar maybe ???!!!) That would make my day

    Plugin Author Rinat Khaziev

    @rinatkhaziev

    I’m gonna release the next version in about a couple of days. I’ll update the topic when the update is shipped.

    uddhava

    @uddhava

    I was wondering if you ever got to resolving the MIME type issue ?
    Didnt see a new version till now.

    Plugin Author Rinat Khaziev

    @rinatkhaziev

    Sorry I got caught up in work, it’s still a pending issue.

    Plugin Author Rinat Khaziev

    @rinatkhaziev

    Kinda took look, but now it should work. At least it worked for me when I was testing the functionality last time.

    Plugin Author Rinat Khaziev

    @rinatkhaziev

    The underlying issue might be that each file can have multiple mime types depending on multiple factors. Here’s the list for psd according to http://filext.com/file-extension/PSD:
    Mime type: image/photoshop, image/x-photoshop, image/psd, application/photoshop, application/psd, zz-application/zz-winassoc-psd

    Here’s a snippet from a similar thread (basically swap mp3 with psd and put photoshop mimes):

    add_filter( 'fu_allowed_mime_types', 'my_fu_allowed_mime_types' );
    function my_fu_allowed_mime_types( $mime_types ) {
        // Array keys should be unique
        // To include all mime-types we use this workaround
        // Part after | could be anything as long as it's unique
        $mime_types['mp3|mp3-am'] = 'audio/mpeg';
        $mime_types['mp3|mp3-xam'] = 'audio/x-mpeg';
        // Include the rest of mp3 mimes
    
        $mime_types['wav'] = 'audio/wav';
        return $mime_types;
    }

    I realize that you probably don’t use the plugin anymore, but leaving this reply for other people

    Plugin Author Rinat Khaziev

    @rinatkhaziev

    The more detailed explanation is in this thread:
    http://wordpress.org/support/topic/audio-file-support?replies=8

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘[Resolved] [bug] Allowed mime types are blocked by Frontend Uploader’ is closed to new replies.
Skip to toolbar