multi site file upload

in the network setting on a multi-user set-up, there is a section called “Upload Settings” that has a fields for “Upload file types”, where it is listed certain files by default and the option of adding more.

however, when adding additional files to this, it does still not work…

am i missing something obvious here or is there additional settings that need to be edits or added? Any help is appreciated.

thanks,

biorn

  • aecnu
    • WP Unicorn

    Greetings biorn,

    however, when adding additional files to this, it does still not work

    I have never had any trouble adding file types to this area nor trouble uploading those very types.

    What kind of file types are you referring too?

    Please advise.

    Cheers, Joe

  • biornt
    • WPMU DEV Initiate

    I added psd to it and i am getting this error:

    ““testimg.psd” has failed to upload due to an error

    Sorry, this file type is not permitted for security reasons.”

    in the upload field it even says this: “Allowed Filetypes: jpg, jpeg, png, gif, mp3, mov, avi, wmv, midi, mid, pdf, psd, stp“, but it does not let me add the psd file to the server. It will upload everything, but on upload completion it gives the error above.

    could this be a server setting?

    biorn

  • Mustafa
    • Syntax Hero

    Hiya biornt,

    That’s about mime control.

    You can check wp-includes/functions.php -> get_allowed_mime_types() function

    for example. If you want to upload po files. You can add

    ‘po’ => ‘application/x-gettext’,

    Maybe you can find custom plugin for that.

  • biornt
    • WPMU DEV Initiate

    so again, this field is kind of useless then since you have to go in and hard code the functions file?

    Then this field should not be there and just allow for whatever is controlled in the functions file then.

    Are there any plugins out there that will do this easy? I know there is an “additional_file_types” plugin, but it requires the developer hard code to that file and to know all the mime names like these: ‘xx’ => ‘???/???’, – is there a list with this information some place?

    biorn

  • Mustafa
    • Syntax Hero

    Hiya biorn,

    Yep I just write a function for that.

    I can’t upload here. Maybe I’ll develop is a plugin but not today.

    Anyway.

    1) Create a php file ex:new_mime.php

    2) use this code

    <?php

    function new_file_type(){
    $file = array('psd' => 'application/photoshop');

    return $file;
    }

    add_action('upload_mimes','new_file_type');
    ?>

    3) add psd type via network settings

    4) upload new_mime.php to mu-plugins folder.

    That’s all.

  • biornt
    • WPMU DEV Initiate

    Mustafa,

    Thank you so much for doing that.

    It “almost” worked :wink: The script did allow to upload a psd file. However, it then does not allow for any other files that were there default.

    not sure why this happened.

    biorn

  • ittikorns
    • WPMU DEV Initiate

    I came up with this, try and tell me whether it works or not :slight_smile:

    Add the code below to your functions.php and I should be working fine. I tested on my custom theme.

    function custom_upload_mimes ($existing_mimes=array()) {

    // Add file extension 'extension' with mime type 'mime/type'
    $existing_mimes['psd'] = 'application/photoshop';

    // and return the new full result
    return $existing_mimes;

    }

    add_filter('upload_mimes', 'custom_upload_mimes');

  • biornt
    • WPMU DEV Initiate

    Thanks to Mustafa and ittikorns for stepping up here. ittikorns edits did it – works like a charm now.

    Thank you so much. Now i gotta find the correct mime types for different 3d files…

    One more question, one the same subject kind of. There is also a field that has the file size you can upload. However, even if you set it to more than 100M it will not allow for that.

    I need to allow files that are more than 100M – where can I set/edit that?

    again, thanks so much everyone.

    biorn

  • aecnu
    • WP Unicorn

    Greetings biorn,

    Happy to hear that you resolved your file type upload problem.

    I need to allow files that are more than 100M – where can I set/edit that?

    This is usually limited by your hosts php.ini file and the set amount shown in the indicator: upload_max_filesize

    To help check what it is currently set at I have attach a phpinfo file in which you want to download, unzip, and then upload to the root directory of your hosting account.

    Next call it up in your browser: http://yourdomain.com/phpinfo.php

    And then find where it says: upload_max_filesize

    This needs to be either changed in your hosts php.ini file or your need to create one and place it as allowed by your host – if indeed they allow php.ini over ride.

    Thank you for being a WPMU Dev Member!

    Cheers, Joe

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.