PhpOffice\PhpPresentation\Shape\Drawing\ZipFile::getMimeType PHP Méthode

getMimeType() public méthode

public getMimeType ( ) : string
Résultat string
    public function getMimeType()
    {
        if (!CommonFile::fileExists($this->getZipFileOut())) {
            throw new \Exception('File ' . $this->getZipFileOut() . ' does not exist');
        }
        $oArchive = new \ZipArchive();
        $oArchive->open($this->getZipFileOut());
        if (!function_exists('getimagesizefromstring')) {
            $uri = 'data://application/octet-stream;base64,' . base64_encode($oArchive->getFromName($this->getZipFileIn()));
            $image = getimagesize($uri);
        } else {
            $image = getimagesizefromstring($oArchive->getFromName($this->getZipFileIn()));
        }
        return image_type_to_mime_type($image[2]);
    }

Usage Example

 public function testMimeType()
 {
     $oDrawing = new ZipFile();
     $oDrawing->setPath($this->fileOk);
     $this->assertEquals('image/gif', $oDrawing->getMimeType());
 }