How the Upload

How the Upload files in other formast is not working
this is an PNG file error: https://screencast.com/t/ic0J69sPCV
"Sorry, this file type is not permitted for security reasons."

In the main site this is setup:
https://screencast.com/t/DLkwZCS5e

And in the theme function file:
add_filter(
'coursepress_allowed_student_mimes', function ($a) {
return array(
'txt' => 'text/plain',
'pdf' => 'application/pdf',
'zip' => 'application/zip',
// Powerpoint files
'ppt|pot|pps' => 'application/vnd.ms-powerpoint',
'png' => 'application/png',
'jpg' => 'application/jpg',
'gif' => 'application/gif',
'tif' => 'application/tif',
// Word files
'doc|docx|dotx|rtf|dot' => 'application/vnd.ms-powerpoint',
// Add further file types here
) ;
}
);

function custom_upload_mimes($existing_mimes = array()) {

// Add *.EPS files to Media upload
$existing_mimes['eps'] = 'application/postscript';
// Add *.AI files to Media upload
$existing_mimes['ai'] = 'application/postscript';
// Add *.AI files to Media upload
$existing_mimes['3ds'] = 'application/postscript';
// Add *.dwg files to Media upload
$existing_mimes['dwg'] = 'application/acad';
// Add *.dwg files to Media upload
$existing_mimes['dwg'] = 'application/x-acad';
// Add *.dwg files to Media upload
$existing_mimes['dwg'] = 'application/autocad_dwg';
// Add *.dwg files to Media upload
$existing_mimes['dwg'] = 'application/dwg';
// Add *.dwg files to Media upload
$existing_mimes['dwg'] = 'application/x-dwg';
// Add *.dwg files to Media upload
$existing_mimes['dwg'] = 'application/x-autocad';
// Add *.dwg files to Media upload
$existing_mimes['dwg'] = 'drawing/dwg';
//add .zip
$existing_mimes['zip'] = 'application/zip';

return $existing_mimes;
}

add_filter('upload_mimes', 'custom_upload_mimes');

  • Sajid
    • DEV MAN’s Sidekick

    Hello morfjord ,
    Hope you are doing good today :slight_smile:

    I just tested the same code on my own test site using latest CoursePress Pro plugin and did not get that error. Its allowing .png files without any issue.

    Could you please make sure that code is actually being applied in your website. Also, where you added the code ? In functions.php file or in mu-plugin ?

    Some times, the priority also needs to be set. Please try following code instead and see if that makes any difference.

    add_filter(
    'coursepress_allowed_student_mimes', function ($a) {
    return array(
    'txt' => 'text/plain',
    'pdf' => 'application/pdf',
    'zip' => 'application/zip',
    // Powerpoint files
    'ppt|pot|pps' => 'application/vnd.ms-powerpoint',
    'png' => 'application/png',
    'jpg' => 'application/jpg',
    'gif' => 'application/gif',
    'tif' => 'application/tif',
    // Word files
    'doc|docx|dotx|rtf|dot' => 'application/vnd.ms-powerpoint',
    // Add further file types here
    ) ;
    },
    999
    );
    
    function custom_upload_mimes($existing_mimes = array()) {
    
    // Add *.EPS files to Media upload
    $existing_mimes['eps'] = 'application/postscript';
    // Add *.AI files to Media upload
    $existing_mimes['ai'] = 'application/postscript';
    // Add *.AI files to Media upload
    $existing_mimes['3ds'] = 'application/postscript';
    // Add *.dwg files to Media upload
    $existing_mimes['dwg'] = 'application/acad';
    // Add *.dwg files to Media upload
    $existing_mimes['dwg'] = 'application/x-acad';
    // Add *.dwg files to Media upload
    $existing_mimes['dwg'] = 'application/autocad_dwg';
    // Add *.dwg files to Media upload
    $existing_mimes['dwg'] = 'application/dwg';
    // Add *.dwg files to Media upload
    $existing_mimes['dwg'] = 'application/x-dwg';
    // Add *.dwg files to Media upload
    $existing_mimes['dwg'] = 'application/x-autocad';
    // Add *.dwg files to Media upload
    $existing_mimes['dwg'] = 'drawing/dwg';
    //add .zip
    $existing_mimes['zip'] = 'application/zip';
    
    return $existing_mimes;
    }
    
    add_filter('upload_mimes', 'custom_upload_mimes',999);

    Take care and have a nice day :slight_smile:

    Best Regards,
    Sajid - WPMU DEV Support

  • Sajid
    • DEV MAN’s Sidekick

    Hello morfjord,
    Hope you are doing good today :slight_smile:

    Can you please try moving the code from functions.php file to mu-plugin ?

    If you go with mu-plugin route then, go to your /wp-content/ folder via FTP, and find the folder called "mu-plugins". If there is no folder with that name, then you'll want to create one. Then, create a file inside that folder, and give the file any name you like and paste the code in there.

    You don't need to activate that plugin, as it will be always be automatically activated. Please be sure to add a PHP start tag at the beginning of the code if you insert this code as a mu-plugin, like this:

    <?php

    If the issue still there then please send in FTP and WordPress admin details so I could take a closer look.

    You can send the requested details via our secure contact form in following format.

    Subject: "Attn: Sajid Javed”
    - WordPress admin username
    - WordPress admin password
    - login url
    - FTP credentials (host/username/password)
    - link back to this thread for reference

    Take care and have a nice day :slight_smile:

    Best Regards,
    Sajid - WPMU DEV Support

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.