Haridarshan Haridarshan - 3 years ago 239
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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download