Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Mime Type for apk files

Tags:

php

.htaccess

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

.htaccess

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

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

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

like image 258
Haridarshan Avatar asked Oct 18 '22 17:10

Haridarshan


1 Answers

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.

like image 159
Martin Vseticka Avatar answered Oct 21 '22 05:10

Martin Vseticka