| | |
| | private function isMediaType(string $type): bool { |
| | - return str_contains(MediaTypeSniffer::isMediaType('', $this->name), $type); |
| | + $data = ''; |
| | + |
| | + // Only attempt to read if it's not a directory and the file exists locally |
| | + if (!$this->isDir && file_exists($this->name)) { |
| | + $handle = @fopen($this->name, 'rb'); |
| | + if ($handle) { |
| | + // Read the first 12 bytes as expected by the Sniffer |
| | + $read = fread($handle, 12); |
| | + if ($read !== false) { |
| | + $data = $read; |
| | + } |
| | + fclose($handle); |
| | + } |
| | + } |
| | + |
| | + return str_contains(MediaTypeSniffer::isMediaType($data, $this->name), $type); |
| | } |
| | |