WordPress 3.6.1: How To Upload swf Files

If you have tried to upload a swf (or exe) file and gotten an error message something like this:

“filename.swf” has failed to upload due to an error
Sorry, this file type is not permitted for security reasons.

That’s because WordPress 3.6.1 has added some new security restrictions in regards to file uploads (http://codex.wordpress.org/Version_3.6.1)

Additional security hardening:

Updated security restrictions around file uploads to mitigate the potential for cross-site scripting. The extensions .swf and .exe are no longer allowed by default, and .htm and .html are only allowed if the user has the ability to use unfiltered HTML.

And while it’s best to take these security changes seriously, in come cases you may need to upload a swf file (or an exe, but I’d never see a need to do that). So if you’d like to allow uploading of a swf file via the Media Manager in WordPress 3.6.1, just add this code to your theme’s functions.php file:

function add_upload_mime_types( $mimes ) {
    if ( function_exists( 'current_user_can' ) )
        $unfiltered = $user ? user_can( $user, 'unfiltered_html' ) : current_user_can( 'unfiltered_html' );
    if ( !empty( $unfiltered ) ) {
        $mimes['swf'] = 'application/x-shockwave-flash';
    return $mimes;
add_filter( 'upload_mimes', 'add_upload_mime_types' );

About Doug Sparling
Web and mobile developer. Ruby, PHP, WordPress, Android, iOS. Buddhist. iPhoneographer. Musician/Composer.

6 Responses to WordPress 3.6.1: How To Upload swf Files

  1. christian says:

    It works!! thank you!

  2. scott says:


    can you do this if your blog is hosted by wordpress? I can’t find where to edit the functions.php file- i’m thinking that may be because of restrictions on wordpress hosted blogs


    • No, this and most other modifications are not possible on blogs hosted at WordPress.com. You do get more flexibility if you pay, but it’s very limited if you are using the free hosting.

  3. ayub majeed says:

    Thanks, perfect solution …

  4. David says:

    Great. Thank you for this post!

  5. Krish says:

    Thanks, Works perfectly!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>