Haridarshan Haridarshan - 8 months ago 82
PHP Question

PHP Mime Type for apk files

Why PHP method

$mime = mime_content_type($filename);
mime-type = application/zip
for apk files?? I've defined apk mimetype in htaccess


<IfModule mod_mime.c>
AddType application/vnd.android.package-archive apk
AddType application/apk apk
AddType application/java-archive jar

<FilesMatch \.apk$>
SetHandler application/vnd.android.package-archive

I've tried all the solutions provided below but still none of them solved the problem. Need help regarding this.


That's because mime_content_type is not affected by .htaccess. However, the documentation specifies that you can set magic.mime file:

string mime_content_type ( string $filename )

Returns the MIME content type for a file as determined by using information from the magic.mime file.

There is also finfo_open (PECL) function that has $magic_file as a parameter.