Skip to content
Permalink
Browse files

Use finfo better.

Improves upon the code suggested in #6779

Refs #6779
  • Loading branch information...
markstory committed Jun 15, 2015
1 parent ed3fbee commit 5dee28d4f2cddfefede4f4048499353e5f5d7474
Showing with 7 additions and 5 deletions.
  1. +7 −5 src/Filesystem/File.php
@@ -14,6 +14,8 @@
*/
namespace Cake\Filesystem;
use finfo;
/**
* Convenience class for reading, writing and appending to files.
*
@@ -554,13 +556,13 @@ public function mime()
if (!$this->exists()) {
return false;
}
if (function_exists('finfo_open')) {
$finfo = finfo_open(FILEINFO_MIME);
$finfo = finfo_file($finfo, $this->pwd());
if (!$finfo) {
if (class_exists('finfo')) {
$finfo = new finfo(FILEINFO_MIME);
$type = $finfo->file($this->pwd());
if (!$type) {
return false;
}
list($type) = explode(';', $finfo);
list($type) = explode(';', $type);
return $type;
}
if (function_exists('mime_content_type')) {

0 comments on commit 5dee28d

Please sign in to comment.
You can’t perform that action at this time.