Title: Version 4 &#8211; Cannot replace pdf
Last modified: September 6, 2022

---

# Version 4 – Cannot replace pdf

 *  Resolved [satnapar](https://wordpress.org/support/users/satnapar/)
 * (@satnapar)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/version-4-cannot-replace-pdf/)
 * Hi there, even though version 3.6.3 works perfectly, after updating to version
   4 and trying to replace a pdf, I get an error telling that this file has a different
   file type and this could probably make some problems. After rolling back to 3.6.3
   same file is replaced with no poblems

Viewing 15 replies - 1 through 15 (of 18 total)

1 [2](https://wordpress.org/support/topic/version-4-cannot-replace-pdf/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/version-4-cannot-replace-pdf/page/2/?output_format=md)

 *  Plugin Support [Gerard Blanco](https://wordpress.org/support/users/sixaxis/)
 * (@sixaxis)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/version-4-cannot-replace-pdf/#post-15986097)
 * Hi satnapar,
 * Could you please send us the old file and the new one? In addition, is the issue
   happening with all files, all PDFs or only this PDF?
 * Finally, can you please send us a screenshot of the actual error? Please take
   the screenshot from the whole browser window, not only the error.
 * Thank you!
 *  Thread Starter [satnapar](https://wordpress.org/support/users/satnapar/)
 * (@satnapar)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/version-4-cannot-replace-pdf/#post-15986142)
 * I am sending you some files that I just tested and the screenshot here [https://we.tl/t-U5ZjSY5ZOm](https://we.tl/t-U5ZjSY5ZOm).
   Version 4 works as expected when replacing image-old.jpg with image-new.jpg. 
   When trying with two different pdfs (pdf-test1-old.pdf replaced with pdf-test1.
   pdf, pdf-test2-old.pdf replaced with pdf-test2.pdf) I am getting the error that
   you can see on the screenshot
    Thank you for your time
 *  Plugin Support [Gerard Blanco](https://wordpress.org/support/users/sixaxis/)
 * (@sixaxis)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/version-4-cannot-replace-pdf/#post-15998420)
 * Thanks, [@satnapar](https://wordpress.org/support/users/satnapar/)!
 * I was able to reproduce the issue, so I’ll forward it to our developers so we
   can take care of it.
 * In the meantime, feel free to ignore the message. It’s just a warning, not an
   error, so nothing will happen.
 * Best,
 *  [StandOutSites](https://wordpress.org/support/users/standoutsites/)
 * (@standoutsites)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/version-4-cannot-replace-pdf/#post-16006498)
 * I’m having the same issue. When replacing a PDF document, I get an error that
   the file format doesn’t match the file being replaced (even though they do, PDF).
   It does replace the document in the end, but error is always there.
 *  [webmarketingmatters](https://wordpress.org/support/users/webmarketingatters/)
 * (@webmarketingatters)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/version-4-cannot-replace-pdf/#post-16044337)
 * Having the same issue on a client’s site, but the attachment is not being replaced
   at all.
 *  Plugin Author [Pedro](https://wordpress.org/support/users/petredobrescu/)
 * (@petredobrescu)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/version-4-cannot-replace-pdf/#post-16054088)
 * Hello to all and thanks for reporting this!
 * After some testing, we narrowed down this issue to the Edge browser because according
   to our tests in Chrome, Safari, and Firefox everything works as expected, with
   no warnings about this, using the test files sent by [@satnapar](https://wordpress.org/support/users/satnapar/)(
   thanks!). Most likely Edge isn’t properly detecting the newly uploaded file’s
   mime type, hence the message. And just to clarify: that message is a warning,
   not an error and the replacement is done correctly, despite the warning.
 * [@webmarketingatters](https://wordpress.org/support/users/webmarketingatters/)
   can you please give us more details about the file you want to replace and the
   new file? Are they both PDF files? What happens exactly when you try to replace
   it, do you get another message besides the one stated at the beginning of this
   thread? I just want to ensure you’re not having a different situation than the
   rest of the reporters.
 * Thank you!
 *  Thread Starter [satnapar](https://wordpress.org/support/users/satnapar/)
 * (@satnapar)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/version-4-cannot-replace-pdf/#post-16054128)
 * [@petredobrescu](https://wordpress.org/support/users/petredobrescu/) , just to
   notice that I am using Firefox on a mac and I am getting the warning
 *  Plugin Author [Pedro](https://wordpress.org/support/users/petredobrescu/)
 * (@petredobrescu)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/version-4-cannot-replace-pdf/#post-16054437)
 * hm, that’s really interesting [@satnapar](https://wordpress.org/support/users/satnapar/),
   can you please tell me which webserver is your site using? Apache/NGINX/Litespeed/
   other?
 *  Thread Starter [satnapar](https://wordpress.org/support/users/satnapar/)
 * (@satnapar)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/version-4-cannot-replace-pdf/#post-16054447)
 * Nginx
 *  [Lukasz](https://wordpress.org/support/users/wpfed/)
 * (@wpfed)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/version-4-cannot-replace-pdf/#post-16055261)
 * Hello,
 * I’m reporting same issue, using fully updated plugin version.
 * **System info:**
 * nginx/1.19.10
    PHP 7.4.23 WordPress 5.9.4 Windows 10, Chrome Version 105.0.5195.127(
   Official Build) (64-bit)
 * I was able to replace the same files on another site running older version of
   enable media replace.
 * I can’t replace PDF at all.
 * Some more console info:
 *     ```
       Checking delayed init 
       emr_admin.js?ver=4.0.0:301 check upload status true
       emr_admin.js?ver=4.0.0:301 file size:513673
       emr_admin.js?ver=4.0.0:301 Not image, media document
       emr_admin.js?ver=4.0.0:301 application/pdf not
       ```
   
 * The UI error: “The replacement file does not have the same file type. This can
   lead to unexpected issues ( – application/pdf )”
    -  This reply was modified 3 years, 7 months ago by [Lukasz](https://wordpress.org/support/users/wpfed/).
    -  This reply was modified 3 years, 7 months ago by [Lukasz](https://wordpress.org/support/users/wpfed/).
 *  [Paul Biron](https://wordpress.org/support/users/pbiron/)
 * (@pbiron)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/version-4-cannot-replace-pdf/#post-16059617)
 * I’m seeing the same problem. Here’s some info I’ve discovered while stepping 
   thru both the 3.6.3 and 4.0.0 code in a debugger:
 * 1. the problem seems to be in the new `FileModel` class (just like the problem
   I reported in [regression in 4.0.0 on windows](https://wordpress.org/support/topic/regression-in-4-0-0-on-windows).
   Same class, but different problem and in this case the problem is **not** Windows-
   specific)
 * 2. the `emrFile::__construct()` method in 3.6.3 uses `wp_check_filetype_and_ext()`
   to get the mime type of the file (the “sourceFile” in this case); whereas, `FileModel::
   getMime()` in 4.0.0 uses `wp_get_image_mime()`, which only works for images.
 * It is because of #2 that version 4.0.0 only knows what the mime type of the sourceFile(
   i.e., the existing file that is being replaced) when it is an image file…and 
   not when it’s a “document” (e.g., a PDF, XLSX, etc). I came across the problem
   when trying to replace an XLSX file.
 * Here’s the environment info: on Windows (where I stepped thru things in the debugger):
 *     ```
       OS: Win11 Pro for Workstations (21H2, 22000.918)
       PHP: 7.4.29
       WP: 6.0.2
       Apache: 2.4.53
       MySQL: 5.7.38
       ```
   
 * And on Linux (where I first discovered the problem on a live site):
 *     ```
       OS: CentOS 7
       PHP 7.4.27
       WP: 6.0.2
       Apache: 2.4.6
       MySQL: 5.7.36
       ```
   
 *  [Lukasz](https://wordpress.org/support/users/wpfed/)
 * (@wpfed)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/version-4-cannot-replace-pdf/#post-16060735)
 * Nice debugging [@pbiron](https://wordpress.org/support/users/pbiron/) ! Which
   debugger and IDE did you use? I’m using Tracy debugger which didn’t show any 
   error but it also doesn’t have step through debugging.
 * [@petredobrescu](https://wordpress.org/support/users/petredobrescu/) the functionality
   does work even with the warning message.
 *  [gypsybytes](https://wordpress.org/support/users/gypsy-bytes/)
 * (@gypsy-bytes)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/version-4-cannot-replace-pdf/#post-16067597)
 * I’m having the same problem trying to replace a zip file. I’m running the latest
   versions of WordPress and the plugin on Chrome on Windows 10.
    I get these error
   messages, but am able to replace the file successfully: The replacement file 
   does not have the same file type. This can lead to unexpected issues ( – application/
   x-zip-compressed ) The replacement file type does not seem to be allowed by WordPress.
   This can lead to unexpected issues
 *  [C-Fusion Multimedia](https://wordpress.org/support/users/cfusionmm/)
 * (@cfusionmm)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/version-4-cannot-replace-pdf/#post-16075638)
 * Same issue here when replacing a PDF. Looks like [@pbiron](https://wordpress.org/support/users/pbiron/)
   located the cause, hoping developer will push a fix soon.
 *  [kato](https://wordpress.org/support/users/kato/)
 * (@kato)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/version-4-cannot-replace-pdf/#post-16139856)
 * Try it anyway with the PDF.
 * I get the error, but it still works. It replaces the PDF with no issues.

Viewing 15 replies - 1 through 15 (of 18 total)

1 [2](https://wordpress.org/support/topic/version-4-cannot-replace-pdf/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/version-4-cannot-replace-pdf/page/2/?output_format=md)

The topic ‘Version 4 – Cannot replace pdf’ is closed to new replies.

 * ![](https://ps.w.org/enable-media-replace/assets/icon-256x256.png?rev=1940728)
 * [Enable Media Replace](https://wordpress.org/plugins/enable-media-replace/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/enable-media-replace/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/enable-media-replace/)
 * [Active Topics](https://wordpress.org/support/plugin/enable-media-replace/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/enable-media-replace/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/enable-media-replace/reviews/)

 * 19 replies
 * 10 participants
 * Last reply from: [Pedro](https://wordpress.org/support/users/petredobrescu/)
 * Last activity: [3 years, 6 months ago](https://wordpress.org/support/topic/version-4-cannot-replace-pdf/page/2/#post-16215311)
 * Status: resolved