• Hi

    I’ve been able to upload product csv files with no problem up until now. Suddenly I am getting this error:

    “Sorry, This File Type Is Not Permitted for Security Reasons”

    I installed WP Add Mime Types plugin to add in the csv type, but it is already there.

    I tried uploading a product csv that I had downloaded and did not change, just in case I had formatted something strangely in the newer file I’d hoped to upload, but the error still occurred. The content of the file has always contained some html in the description value, and though this seems to have been a problem historically for others, it has never been a problem for me, so I don’t think this is the problem.

    I’ve tried deactivating plugins, no change.

    My next option is, I suppose, to add:

    define(‘ALLOW_UNFILTERED_UPLOADS’, true);

    to my wp-config file, but I am reluctant to so this due to security warnings.

    What could be causing this and what is the best way to fix?

    Thanks

    Becky

Viewing 15 replies - 1 through 15 (of 15 total)
  • Add this temporarily simply to see if it resolves your issue :
    define('ALLOW_UNFILTERED_UPLOADS', true);

    If it seems to work, then remove it, and move to this method in your functions file :

    function my_custom_mime_types( $mimes ) {
    $mimes['csv'] = 'text/csv';
    unset( $mimes['exe'] );
     return $mimes;
    }
    add_filter( 'upload_mimes', 'my_custom_mime_types' );

    If that fails, check your disk space.

    Thread Starter beckseden

    (@beckseden)

    Hi @corrinarusso

    Add that to where? wp-config?

    Thanks

    Becky

    Sorry –

    Add this :
    define('ALLOW_UNFILTERED_UPLOADS', true);

    to your /wp-config.php file to test.

    Then add this to the bottom of your :
    /website.com/wp-content/themes/your-theme-child/functions.php
    file.

    function my_custom_mime_types( $mimes ) {
    $mimes['csv'] = 'text/csv';
    unset( $mimes['exe'] );
     return $mimes;
    }
    add_filter( 'upload_mimes', 'my_custom_mime_types' );

    You can reach it under Appearance –> Theme Editor

    or here :
    https://www.chicmouldings.com/wp-admin/theme-editor.php?file=functions.php&theme=dt-the7-child

    • This reply was modified 5 years, 4 months ago by corrinarusso.
    Thread Starter beckseden

    (@beckseden)

    Hi @corrinarusso

    There is no wp-config in my theme editor. Is that because I’m using a child theme> And if so, how do I add it in?

    Thank you so much for your help

    Becky

    No.
    wp-config.php is at your root – you will need to use FTP or Control Panel File Manager to access.

    https://www.wpbeginner.com/beginners-guide/how-to-edit-wp-config-php-file-in-wordpress/

    Thread Starter beckseden

    (@beckseden)

    Hiya @corrinarusso

    Ah, I see. I was following your instructions “You can reach it under Appearance –> Theme Editor” 🙂

    No probs – can go into Cpanel file manager. Thanks, I’ll take a look at that now.

    Becky

    Right – just the functions.php file is under your Theme Editor.

    Thread Starter beckseden

    (@beckseden)

    Oh, I’m with you now, thanks.

    The temp fix in your wp-config file is simply to determine “if you can successfully upload the csv”. If you can’t, then more troubleshooting investigation will be required.
    Perhaps at the server level.

    Thread Starter beckseden

    (@beckseden)

    Hi @corrinarusso

    So, the test part worked (hooray!) – no longer getting error message when i try to upload csv.

    So imoved onto step 2, but was unable to add that script to my functions.php

    error was:

    “Something went wrong. Your change may not have been saved. Please try again. There is also a chance that you may need to manually fix and upload the file over http://FTP.”

    Before I go the ftp route, can i check I am taking the steps correctly? Should I have removed the code I added to the wp-config file to do the test before adding that code to functions php?

    Again, thank you. I feel like we are getting somewhere.

    If I am leaving that code in the wp-config file, I have read it can affect site security. Is that people being over dramatic, or is it a real issue i need to consider?

    Thanks

    Becky

    > Should I have removed the code I added to the wp-config file to
    > do the test before adding that code to functions php

    Yes.

    Did the code you added to this file :
    https://www.chicmouldings.com/wp-admin/theme-editor.php?file=functions.php&theme=dt-the7-child
    save successfully ?

    You may not be able to use the WordPress backend to edit this file (due to permissions).
    If it save successfully, the browser will tell you.

    If not – yes, download the file, add the code, upload the file.

    Thread Starter beckseden

    (@beckseden)

    Hi

    No it didn’t save, and still doesn’t after removing the test code from wp-config.

    I edited the funtions.php file in file manager instead. But wasn’t able to upload a csv after doing that, unfortunately. So close! 🙂

    Becky

    Same error ?

    Thread Starter beckseden

    (@beckseden)

    Hiya. @corrinarusso

    Sorry for the delay. Yes, same error.

    I’m working around it by just adding

    define(‘ALLOW_UNFILTERED_UPLOADS’, true);

    to my wp-config , uploading the csv, then deleting the code from my wp-config again. Not ideal, but at least I can get the work done.

    My host says I can just leave the code in my WP config file if my security is strong enough. I have no idea if it is, so am playing safe.

    Thanks all the same, I really appreciate your time.

    Becky

    If your users, groups and permissions are set properly on the server, you should be okay. You can also monitor the file structure to be notified of new uploaded files.

    Changing File Permissions

    https://lifehacker.com/thefolderspy-executes-programs-automatically-while-moni-5548191

    If you are the only one uploading, and it’s not overly tedious, then your resolution is not terrible.

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘Error when uploading CSV “Sorry, This File Type…….’ is closed to new replies.