WordPress.org

Ready to get started?Download WordPress

Forums

Frontend Uploader
[resolved] [bug] Allowed mime types are blocked by Frontend Uploader (16 posts)

  1. uddhava
    Member
    Posted 1 year ago #

    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/

  2. uddhava
    Member
    Posted 1 year ago #

    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.

  3. uddhava
    Member
    Posted 1 year ago #

    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

  4. Rinat Khaziev
    Member
    Plugin Author

    Posted 1 year ago #

    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?

  5. uddhava
    Member
    Posted 1 year ago #

    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.

  6. Rinat Khaziev
    Member
    Plugin Author

    Posted 1 year ago #

    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;
    }
  7. uddhava
    Member
    Posted 1 year ago #

    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.

  8. uddhava
    Member
    Posted 1 year ago #

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

  9. Rinat Khaziev
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks uddhava,

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

  10. uddhava
    Member
    Posted 1 year ago #

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

  11. Rinat Khaziev
    Member
    Plugin Author

    Posted 1 year ago #

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

  12. uddhava
    Member
    Posted 1 year ago #

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

  13. Rinat Khaziev
    Member
    Plugin Author

    Posted 1 year ago #

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

  14. Rinat Khaziev
    Member
    Plugin Author

    Posted 1 year ago #

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

  15. Rinat Khaziev
    Member
    Plugin Author

    Posted 1 year ago #

    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

  16. Rinat Khaziev
    Member
    Plugin Author

    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic