WordPress 4.7.x: Issues Uploading Images (or other media)

On Friday, February 10th 2017, one of our multi-site WordPress installs began giving errors when attempting to upload media (images, etc.) and would not allow uploads.

"docname.png" has failed to upload.
Sorry, this file type is not permitted for security reasons.

After a big of Googling and reading, I found a post that helped. It seems there is a not bug in WordPress 4.7.2 that leads to this issue.

The fix on the first site on which I encountered this issue was fairly easy.  I installed the Disable Real Mime Check plugin, then went to settings for the WP Add Mime Types plugin (as Network Admin) and clicked the Save button.

Done! We are now able to upload .png files and attach them to pages.

This morning (Sunday, February 12, 2017), we began experiencing the same issue on another WordPress site. I tried the magic that worked before (added Disable Real Mime Check plugin and clicked Save in the settings for WP Add Mime Types. We could now upload .png files, but they didn’t display either in the Media Library or on the pages to which they were attached. Ugh!

More poking around, reading and testing led to discovery that requests for  images (and other uploaded media) returned a 403 Forbidden error.

NOTE: I used “curl -I http://mysite/image_url” to ferret out this info.

As I looked at the URL WordPress was giving for the image, I noted that it didn’t include wp-content as I expected.  Instead, the URL was: http://mysite/subsite/files/2017/02/image.png. Hmmmm. no directory called files exists on that server.

Looking that the top-level .htaccess file, I found that media files for multi-site WP installs are served by ms-files.php.

# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]

A little more Googling and reading, I found the page: https://codex.wordpress.org/Multisite_Network_Administration.

This turned out to be my answer.  My .htaccess was the wrong one!  I replaced it with the WordPress 3.0 through 3.4.2 .htaccess example from that page and everything worked!!

Hurray!

Happy Slacking!
Stu…

Leave a Comment