Getting files mime types - Mission impossible ? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Getting files mime types - Mission impossible ? (/showthread.php?tid=33429) |
Getting files mime types - Mission impossible ? - El Forum - 08-25-2010 [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 ? Getting files mime types - Mission impossible ? - El Forum - 08-26-2010 [eluser]Twisted1919[/eluser] Oh really ? Nobody ? Nothing ? Getting files mime types - Mission impossible ? - El Forum - 08-26-2010 [eluser]danmontgomery[/eluser] Code: $data = $this->upload->data(); http://ellislab.com/codeigniter/user-guide/libraries/file_uploading.html Getting files mime types - Mission impossible ? - El Forum - 08-26-2010 [eluser]Bramme[/eluser] http://php.net/manual/en/function.mime-content-type.php ? Edit: whoops, I post too quicly, also deprecated. Getting files mime types - Mission impossible ? - El Forum - 08-26-2010 [eluser]davidbehler[/eluser] And even cURL is not available with all hosting services... Getting files mime types - Mission impossible ? - El Forum - 08-26-2010 [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 ? |