Support » Plugin: WP Document Revisions » Potential Fix – Delivering Corrupt docx

  • Resolved WorldWideWebb


    Love the plugin, but we’ve been running into an issue lately in which viewing any docx (haven’t fully tested this with xlsx and pptx, but excel files have so far exhibited the same behavior) comes back as corrupted. We try to either open or save the file out and open it with Word, and we either see gibberish or the file appears to be completely corrupted. I’ve made sure that the mime type being delivered by the web server (apache) is correct, and I’ve even tried bumping that back down to the old mime type for regular doc files, and none of that worked. After a lot of googling, I’ve seen other users with this issue (a couple said that they had conflicting plugins and disabling them corrected the issue – no such luck for me).

    I had also isolated a few other possibilities, such as a corrupt file to begin with, or an issue on upload (I pulled the uploaded & renamed file directly off of the server with FTP and hit the fully-qualified path to the file itself – both worked). Definitely something to do with when the file was being returned by the plugin.

    What finally worked for me (not sure if this is worth including in the plugin in a future fix) was to clean the output buffering and run flush() right before the file is delivered (immediately before “read_file( $file)” in the “serve_file” function. Added the following 2 lines:


    Hope this helps someone.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thanks for this! It saved my bacon when Firefox and Internet Explorer were having trouble previewing my PDFs.

    What file do I make this update too?

    It’s the main plugin file: wp-document-revisions/wp-document-revisions.php

    Do a Ctrl-F for “serve_file”, then scroll to the closing curly brace of that method. Add the lines directly before the “read_file( $file);” line.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Potential Fix – Delivering Corrupt docx’ is closed to new replies.