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 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. 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" 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? 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"; } 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. Link to comment https://forums.phpfreaks.com/topic/263578-finfo/#findComment-1350803 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.