Beispiel #1
0
 /**
  * Determines the extension for the target file based on the input file..
  */
 protected static function getTargetFile($source, $mime, $target)
 {
     $origExtension = binarypool_render::getFileExtension($source);
     $allowedExtensions = array('gif', 'png', 'jpg');
     $newExtension = $origExtension;
     switch ($mime) {
         case 'image/bmp':
         case 'image/tiff':
         case 'application/octet-stream':
         case 'image/jpeg':
             $newExtension = 'jpg';
             break;
         case 'application/pdf':
         case 'image/pdf':
         case 'image/png':
             $newExtension = 'png';
             break;
         case 'image/gif':
             $newExtension = 'gif';
             break;
     }
     if ($newExtension == '' || !in_array($newExtension, $allowedExtensions)) {
         $newExtension = 'jpg';
     }
     return $target . '.' . $newExtension;
 }