getMimeType() public method

Get mime type
public getMimeType ( string $key ) : string
$key string
return string
Beispiel #1
0
 /**
  * Replace item
  *
  * @param string $key
  * @param Zend_Form_Element_File $file
  * @return void
  * @throws InvalidArgumentException
  */
 public function replaceItem($key, \Zend_Form_Element_File $file)
 {
     $oldMime = current(explode(';', $this->storage->getMimeType($key)));
     $newMime = current(explode(';', $file->getMimeType()));
     if ($oldMime != $newMime && !(in_array($oldMime, self::$equivalentMimeTypes) && in_array($newMime, self::$equivalentMimeTypes))) {
         throw new \InvalidArgumentException(sprintf('You can only replace a file with a file of the same type.  The original file is of type "%s", and the file you uploaded was of type "%s".', $oldMime, $newMime));
     }
     $this->storage->storeItem($key, file_get_contents($file->getFileName()));
 }