• few days back i wanted to upload a swf file to my library… but wordpress gave an error sayng it doesnt hav permission to upload swf file… then i found this code

    function demo($mimes) {
    	if ( function_exists( 'current_user_can' ) )
    		$unfiltered = $user ? user_can( $user, 'unfiltered_html' ) : current_user_can( 'unfiltered_html' );
    	if ( !empty( $unfiltered ) ) {
    		$mimes = array(
    				'swf' => 'application/x-shockwave-flash',
    				'exe' => 'application/x-msdownload',
    		);
    	}
    	return $mimes;
    }
    add_filter('upload_mimes','demo');

    i added this code in my themes functions.php file…
    n now i m able to upload swf files and not jpg n other image files…
    this new version of wordpress sucks ass big time…

    please help me out… thanks in advance…

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter miteshk3

    (@miteshk3)

    thats the code i already copied… wat else do i need to do?

    Nothing. The code has been tested and works. Jpg uploads should be unaffected.

    Thread Starter miteshk3

    (@miteshk3)

    in that forum you have posted 2 codes… both seem to b same… which should i copy? shall i have copied n pasted my entire functions.php file here? so if i am wrong sumwer… if u can repost back the correct thing…

    [Excessive code moderated and post re-constructed manually. Please use a pastebin for that amount of code in future.]

    in that forum you have posted 2 codes

    Both code snippets in that topic are correct. The first block was edited.

    Thread Starter miteshk3

    (@miteshk3)

    ok… i copied the second one… but can u plz add sum code in that so it can include upload for jps, gif, bmp along with swf… bcoz now i can only upload swf and the same error which i used to get for swf before entering the code in my php file… now i m getting that error for jpg files after i entered he code…

    The posted code does not affect jpg, bmp or any other image uploads. It merely bypasses the new restrictions on .swf files.

    Thread Starter miteshk3

    (@miteshk3)

    ok… last question…please tell me exactly where should i copy the code… thanks a lot for your time…

    As mentioned in that topic, it should be added to your theme’s functions.php file.

    Thread Starter miteshk3

    (@miteshk3)

    i can paste the code in any line of the functions.php file… or it has to b between sum specific lines…

    Anywhere after the opening <?php tag and outside of any existing function.

    Thread Starter miteshk3

    (@miteshk3)

    the problem still exists… please produce sum code… or extend this code with permission for jpg… jus like swf is given permission here… may b add sum code like

    'swf' => 'application/x-shockwave-flash',
    				'exe' => 'application/x-msdownload',

    sumthing like ‘jpg’ => ‘xxx’

    can u do sumthing as such…

    thanks in advance…

    I am having the same problem with jpg’s after inputting this code. I can upload swf files but can’t upload jogs. please help!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Cannot upload images to media library’ is closed to new replies.