I have been having a problem with the media browser uploader for a couple days since I enabled FORCE_SSL_ADMIN in my wp-config.php file. I finally got some time tonight to look into the issue and I am embarrassed it took me so long to resolve. This was a classic example of trying to make something more complicated than it really was. The issue ended up being with a WordPress plugin I had installed called Flexible Uploader. This plugin provides all the functionality of the flash media uploader to the browser media uploader. It turns out that this plugin has not been updated in a long time and some of the URL building functions have changed in the newer versions of WordPress. Below I explain how to easily resolve the issue.
Update Flexible Uploader WordPress Plugin To Work With WordPress 2.8+:
To update the Flexible Uploader plugin to work with FORCE_SSL_ADMIN you simply need to modify one line in the flexible-upload-wp25.php file which is located in “wp-content/plugins/flexible-upload”. You will need to modify the $form_action_url variable on line 177 as shown below.
Original flexible-upload-wp25.php Line 177:
- $form_action_url = get_option('siteurl') . "/wp-admin/media-upload.php?type=image&tab=type&post_id=$post_id";
Modified flexible-upload-wp25.php Line 177 To Work With WordPress 2.8+:
- $form_action_url = admin_url("media-upload.php?type=image&tab=type&post_id=$post_id");
The symptoms of the problem I was experiencing included appearing to be able to upload an image without issue using the browser media uploader in the WordPress admin. The image was not being uploaded and it appeared that a 302 redirect from HTTP to HTTPS was causing the problem. Also everything else in wp-admin linked to HTTPS except for the upload button for images which still linked to HTTP. I originally thought the issue to be with media-upload.php or includes/media.php but the entire time if I had first looked at the plugins I would have been able to resolve the issue much quicker.