hackalive Posted June 3, 2012 Share Posted June 3, 2012 Hi guys I am using this code: $file_info = new finfo(FILEINFO_MIME); // object oriented approach! $mime_type = $file_info->buffer(file_get_contents($file)); // e.g. gives "image/jpeg" switch($mime_type) { case "image/jpeg": echo "IMAGE"; } However the code is returning: image/jpeg; charset=binary How can I make it so it does not return a charset etc? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/263578-finfo/ Share on other sites More sharing options...
requinix Posted June 3, 2012 Share Posted June 3, 2012 Pass ->buffer() the FILEINFO_MIME_TYPE option. Quote Link to comment https://forums.phpfreaks.com/topic/263578-finfo/#findComment-1350794 Share on other sites More sharing options...
hackalive Posted June 3, 2012 Author Share Posted June 3, 2012 I already have $mime_type = $file_info->buffer(file_get_contents($file)); // e.g. gives "image/jpeg" Quote Link to comment https://forums.phpfreaks.com/topic/263578-finfo/#findComment-1350796 Share on other sites More sharing options...
requinix Posted June 3, 2012 Share Posted June 3, 2012 ...Where? Quote Link to comment https://forums.phpfreaks.com/topic/263578-finfo/#findComment-1350797 Share on other sites More sharing options...
hackalive Posted June 3, 2012 Author Share Posted June 3, 2012 Repeat of code from original post $file_info = new finfo(FILEINFO_MIME); // object oriented approach! $mime_type = $file_info->buffer(file_get_contents($file)); // e.g. gives "image/jpeg" switch($mime_type) { case "image/jpeg": echo "IMAGE"; } Quote Link to comment https://forums.phpfreaks.com/topic/263578-finfo/#findComment-1350798 Share on other sites More sharing options...
requinix Posted June 3, 2012 Share Posted June 3, 2012 I should have been more specific: I see a FILEINFO_MIME but not a FILEINFO_MIME_TYPE. Quote Link to comment https://forums.phpfreaks.com/topic/263578-finfo/#findComment-1350803 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.