Getting files mime types - Mission impossible ? |
[eluser]Twisted1919[/eluser]
So, how come there's no reliable native way in php to get the mime type of a file ? I am looking for a solution for days . What i can see so far : --> Fileinfo - the php extension . Is not available in most of the hosting services, therefore is not reliable for an application that needs to be moved from server to server . --> get_mime_type() - same shit, it's old , deprectaed, and most of the hosting servers don't have it . Sure, for images/flash we can use getimagesize() but for the other types ? One would say to use exec('file -bi '.$file_name); but how many hosting services have functions like exec/system/shellexec enabled ? You can have it only if you have a dedicated/vps server but is not worth the risk. I end up using cURL to get the mime type of a file (how lame is that???) To be more detailed : Code: if(class_exists('finfo')) This works fine enough and is reliable, but really, do we have to end with using curl to get the mime type of a file ??? Do you have other reliable ways of doing this ?
[eluser]danmontgomery[/eluser]
Code: $data = $this->upload->data(); http://ellislab.com/codeigniter/user-gui...ading.html
[eluser]Bramme[/eluser]
http://php.net/manual/en/function.mime-content-type.php ? Edit: whoops, I post too quicly, also deprecated.
[eluser]davidbehler[/eluser]
And even cURL is not available with all hosting services...
[eluser]Twisted1919[/eluser]
@noctrum. I know about that, don't worry, the problem is not of getting the mime type after i upload the file, rather than get it for every file i want . Basically i need to run some file checks from time to time (don't tell me to run a checksum) for various reasons (client decision). @waldmaister. Yes i know, but is more available than finfo or mime_content_type() and it seems to be the only way you can do it in php at this moment without installing extensions . So, what do we do ? |
Welcome Guest, Not a member yet? Register Sign In |