Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter wpcodr

    (@wpcodr)

    OK, I figured it out.

    There are at least 5 but possibly 8 or more places that all define MIME types and file extensions. If they don’t all match then things break in different places making it difficult to understand what is happening. It’s a stupidly complex interaction of Javascript, WordPress, WordPress settings, PHP, and the host OS (and possibly the client OS, desktop environment, browser, etc).

    On top of that WordPress mangles types like x-patch/x-diff and doesn’t seem to understand MIME aliases.

    • This reply was modified 2 years, 9 months ago by wpcodr.
    Thread Starter wpcodr

    (@wpcodr)

    I fixed the code.

    Thread Starter wpcodr

    (@wpcodr)

    I reverted all changes and tried the File Upload Types plugin, it doesn’t work either.

    I note when using the plugin it will sometimes work if you get the MIME type exactly right for whatever is expecting it. For example “xz” MUST be “application/x-xz” or it won’t work (what’s the point of configuring the type if you can’t actually configure it?!). If you have a nonstandard type it doesn’t seem to work at all under any circumstances. Where is this master MIME type list coming from?

    Even so, text/x-diff is the official MIME type of .patch files. This MIME type exists in the default OS install so it’s everywhere and it’s even coded in the WordPress sources yet it still can’t be made to work at all. ?????

    • This reply was modified 2 years, 9 months ago by wpcodr.
    Thread Starter wpcodr

    (@wpcodr)

    This seems to be blocked in the Javascript before it ever gets to the server. For example wp_check_filetype_and_ext() is never called. The PHP results from the filtering and such look fine.

    In the Javascript it seems like it’s looking for a MIME type of “x-patch” regardless of what I have configured for the type. Putting x-patch in the PHP filtering functions makes it get to the server but now the server is returning 500 internal error with no logs. Err..

    Thread Starter wpcodr

    (@wpcodr)

    Oh, I finally got xz to work by adding it to wp_get_mime_types() and wp_get_ext_types(). However, other files still don’t work. For example text files with “patch” extension do not work even though I have the entries in both functions and of course still in the Network settings for the site.

    Even editing the entries for “patch” to make it use the xz MIME type still doesn’t work.

    I’m really confused.

    Thread Starter wpcodr

    (@wpcodr)

    On a multisite check_upload_mimes() is suppose to filter using the option in network settings where I have added the types. In fact, tracing the code I can see my custom types returned from the filter.

    I’m afraid something else may be going on. Could this be a bug in the Javascript code?

    Thread Starter wpcodr

    (@wpcodr)

    Exactly what I was looking for. Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)