Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you're like me and may or may not be using php>=5.3.0 servers for whatever reason and want to use one set of code for all servers, and perhaps insist on involving the mime_content_type function somehow for servers that do not have Fileinfo, then you can use a half-arsed solution like mine, which is to make a replacement function which is that on php>=5.3.0 it uses Fileinfo, and on lower versions, if the filename ends in a specific string unique to something you want to override, it returns your hardcoded value, and calls mime_content_type() for all other types. However, of course this will NOT work if the file is of a type that mime_content_type() incorrectly detects and where the file name does not end in an extension, but that should be very rare.</p> <p>Such a solution might look something like this:</p> <pre><code>function _mime_content_type($filename) { //mime_content_type replacement that uses Fileinfo native to php&gt;=5.3.0 if( phpversion() &gt;= '5.3.0' ) { $result = new finfo(); if (is_resource($result) === true) { return $result-&gt;file($filename, FILEINFO_MIME_TYPE); } } else { if( substr( $filename, -5, 5 ) == '.docx' ) return 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; else if( substr( $filename, -5, 5 ) == '.xlsx' ) return 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; else if( substr( $filename, -5, 5 ) == '.pptx' ) return 'application/vnd.openxmlformats-officedocument.spreadsheetml.presentation'; //amend this with manual overrides to your heart's desire return mime_content_type( $filename ); } } </code></pre> <p>and then you simply have to replace all your calls to mime_content_type with calls to _mime_content_type.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload