当前位置: 首页>>代码示例>>PHP>>正文


PHP File::getMimeType方法代码示例

本文整理汇总了PHP中File::getMimeType方法的典型用法代码示例。如果您正苦于以下问题:PHP File::getMimeType方法的具体用法?PHP File::getMimeType怎么用?PHP File::getMimeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在File的用法示例。


在下文中一共展示了File::getMimeType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test

 /**
  * Runs the test.
  */
 public function test()
 {
     $path = DIR_FILES . '/mail/logo.gif';
     $name = 'logo.gif';
     $mimeType = 'image/gif';
     $attachment = new File($path, $name, $mimeType);
     $this->assertEquals(file_get_contents($path), $attachment->getContent());
     $this->assertEquals($name, $attachment->getName());
     $this->assertEquals($mimeType, $attachment->getMimeType());
     $this->assertEquals(\Jyxo\Mail\Email\Attachment::DISPOSITION_ATTACHMENT, $attachment->getDisposition());
     $this->assertFalse($attachment->isInline());
     $this->assertEquals('', $attachment->getCid());
     $this->assertEquals('', $attachment->getEncoding());
 }
开发者ID:JerryCR,项目名称:php-2,代码行数:17,代码来源:FileTest.php

示例2: fromRequest

 function fromRequest()
 {
     $data = parent::fromRequest();
     $fields = $this->meta['fields'];
     if (array_key_exists('mime_type', $fields) && array_key_exists('from_db', $fields) && array_key_exists('content', $fields)) {
         switch (true) {
             case !empty($data['mime_type']):
                 break;
             case !empty($data['content']['type']):
                 $data['mime_type'] = $data['content']['type'];
                 break;
         }
         if (!empty($data['content']['tmp_name'])) {
             //Mime type first
             if (empty($data['mime_type'])) {
                 $data['mime_type'] = File::getMimeType($data['content']['tmp_name'], $this->default_type);
             }
             $data['meta_info'] = $this->getMetaInfo(array($data['content']['tmp_name'], $data['content']['name']));
             //Overwrite content with file contents
             if ($data['from_db']) {
                 $data['content'] = file_get_contents($data['content']['tmp_name']);
             } else {
                 $folder = self::checkUploadFolder($this->meta['table']);
                 if ($folder) {
                     //We add the timestamp to ensure that the name is unique
                     $destination = $folder . time() . '.' . basename($data['content']['name']);
                     if (move_uploaded_file($data['content']['tmp_name'], $destination)) {
                         $data['content'] = $destination;
                     } else {
                         Backend::addError('Could not upload file');
                         $data = false;
                     }
                 } else {
                     $data = false;
                 }
             }
         }
     }
     return $data;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:40,代码来源:FileObject.obj.php

示例3: getThumbPrevText

 /**
  * Make the text under the image to say what size preview
  *
  * @param $params Array parameters for thumbnail
  * @param $sizeLinkBigImagePreview HTML for the current size
  * @return string HTML output
  */
 private function getThumbPrevText($params, $sizeLinkBigImagePreview)
 {
     if ($sizeLinkBigImagePreview) {
         // Show a different message of preview is different format from original.
         $previewTypeDiffers = false;
         $origExt = $thumbExt = $this->displayImg->getExtension();
         if ($this->displayImg->getHandler()) {
             $origMime = $this->displayImg->getMimeType();
             $typeParams = $params;
             $this->displayImg->getHandler()->normaliseParams($this->displayImg, $typeParams);
             list($thumbExt, $thumbMime) = $this->displayImg->getHandler()->getThumbType($origExt, $origMime, $typeParams);
             if ($thumbMime !== $origMime) {
                 $previewTypeDiffers = true;
             }
         }
         if ($previewTypeDiffers) {
             return $this->getContext()->msg('show-big-image-preview-differ')->rawParams($sizeLinkBigImagePreview)->params(strtoupper($origExt))->params(strtoupper($thumbExt))->parse();
         } else {
             return $this->getContext()->msg('show-big-image-preview')->rawParams($sizeLinkBigImagePreview)->parse();
         }
     } else {
         return '';
     }
 }
开发者ID:OrBin,项目名称:mediawiki,代码行数:31,代码来源:ImagePage.php

示例4: isImageAreaOkForThumbnaling

 /**
  * Check if the file is smaller than the maximum image area for thumbnailing.
  *
  * Runs the 'BitmapHandlerCheckImageArea' hook.
  *
  * @param File $file
  * @param array $params
  * @return bool
  * @since 1.25
  */
 public function isImageAreaOkForThumbnaling($file, &$params)
 {
     global $wgMaxImageArea;
     # For historical reasons, hook starts with BitmapHandler
     $checkImageAreaHookResult = null;
     Hooks::run('BitmapHandlerCheckImageArea', array($file, &$params, &$checkImageAreaHookResult));
     if (!is_null($checkImageAreaHookResult)) {
         // was set by hook, so return that value
         return (bool) $checkImageAreaHookResult;
     }
     $srcWidth = $file->getWidth($params['page']);
     $srcHeight = $file->getHeight($params['page']);
     if ($srcWidth * $srcHeight > $wgMaxImageArea && !($file->getMimeType() == 'image/jpeg' && $this->getScalerType(false, false) == 'im')) {
         # Only ImageMagick can efficiently downsize jpg images without loading
         # the entire file in memory
         return false;
     }
     return true;
 }
开发者ID:xfstudio,项目名称:mediawiki,代码行数:29,代码来源:TransformationalImageHandler.php

示例5: writeViewData

 /**
  * writeViewData
  * @param File $objFile
  * @author Cornelius Hansjakob <cha@massiveart.at>
  * @version 1.0
  */
 private function writeViewData(File &$objFile)
 {
     $this->core->logger->debug('media->controllers->UploadController->writeViewData()');
     $this->view->assign('fileId', $objFile->getId());
     $this->view->assign('fileFileId', $objFile->getFileId());
     $this->view->assign('fileExtension', $objFile->getExtension());
     $this->view->assign('fileTitle', $objFile->getTitle());
     $this->view->assign('mimeType', $objFile->getMimeType());
     $this->view->assign('strDefaultDescription', 'Beschreibung hinzufügen...');
     // TODO : guiTexts
     $this->view->assign('languageId', 1);
     // TODO : language
 }
开发者ID:BGCX261,项目名称:zoolu-svn-to-git,代码行数:19,代码来源:UploadController.php

示例6: getGeneralLongDesc

 /**
  * Used instead of getShortDesc if there is no handler registered for file.
  *
  * @param File $file
  * @return string
  */
 static function getGeneralLongDesc($file)
 {
     global $wgLang;
     return wfMessage('file-info', $wgLang->formatSize($file->getSize()), $file->getMimeType())->parse();
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:11,代码来源:MediaHandler.php

示例7: getLongDesc

 /**
  * @param File $file
  * @return string
  */
 function getLongDesc($file)
 {
     global $wgLang;
     $pages = $file->pageCount();
     $size = htmlspecialchars($wgLang->formatSize($file->getSize()));
     if ($pages === false || $pages <= 1) {
         $msg = wfMessage('file-info-size')->numParams($file->getWidth(), $file->getHeight())->params($size, '<span class="mime-type">' . $file->getMimeType() . '</span>')->parse();
     } else {
         $msg = wfMessage('file-info-size-pages')->numParams($file->getWidth(), $file->getHeight())->params($size, '<span class="mime-type">' . $file->getMimeType() . '</span>')->numParams($pages)->parse();
     }
     return $msg;
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:16,代码来源:ImageHandler.php

示例8: createFromFileByMime

 /**
  * @param string $path
  * @return resource GD image
  * @throws Exception
  */
 private static function createFromFileByMime($path)
 {
     $mime = File::getMimeType($path);
     switch ($mime) {
         case 'image/jpeg':
             $img = imagecreatefromjpeg($path);
             break;
         case 'image/gif':
             $img = imagecreatefromgif($path);
             break;
         case 'image/png':
             $img = imagecreatefrompng($path);
             break;
         default:
             throw new Exception('can`t create thumbnail: unknown image type');
     }
     if (!$img) {
         throw new Exception('can`t create thumbnail: can`t create image handle from file ' . $path);
     }
     return $img;
 }
开发者ID:colibri-fw,项目名称:util,代码行数:26,代码来源:Image.php

示例9: checkExtensionCompatibility

 /**
  * Checks if file extensions are compatible
  *
  * @param $old File Old file
  * @param $new string New name
  *
  * @return bool|null
  */
 static function checkExtensionCompatibility(File $old, $new)
 {
     $oldMime = $old->getMimeType();
     $n = strrpos($new, '.');
     $newExt = self::normalizeExtension($n ? substr($new, $n + 1) : '');
     $mimeMagic = MimeMagic::singleton();
     /** Wikia change start, author Jacek Jursza, bug id: 31194 - not able to rename video files **/
     $result = $mimeMagic->isMatchingExtension($newExt, $oldMime);
     wfRunHooks('File::checkExtensionCompatibilityResult', array(&$result, &$old, &$oldMime, &$newExt));
     return $result;
     /** Wikia change end **/
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:20,代码来源:File.php

示例10: getVipsHandler

	/**
	 * Return the appropriate im_XXX2vips handler for this file
	 * @param File $file
	 * @return mixed String or false
	 */
	public static function getVipsHandler( $file ) {
		list( $major, $minor ) = File::splitMime( $file->getMimeType() );

		if ( $major == 'image' && in_array( $minor, array( 'jpeg', 'png', 'tiff' ) ) ) {
			return "im_{$minor}2vips";
		} else {
			return false;
		}
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:14,代码来源:VipsScaler_body.php

示例11: setFile

 public function setFile(File $toSave)
 {
     $permissionEngine = PermissionEngine::getInstance();
     if (!$permissionEngine->currentUserCanDo('uploadFile')) {
         return false;
     }
     $database = Database::getInstance();
     if (!$database->isConnected()) {
         return false;
     }
     $validator = new checkIfKnownMimeType();
     if (!$validator->validate($toSave->getMimeType())) {
         return false;
     }
     if (!is_readable($toSave->getLocation())) {
         return false;
     }
     $id = $database->escapeString($toSave->getID());
     $dateUploaded = $database->escapeString($toSave->getUploadedDate()->format('Y-m-d H:i:s'));
     $title = $database->escapeString(strip_tags($toSave->getTitle()));
     $mimeType = $database->escapeString($toSave->getMimeType());
     $size = $database->escapeString($toSave->getSize());
     $location = $database->escapeString($toSave->getLocation());
     $nodeID = $database->escapeString($toSave->getNodeID());
     $uploader = $database->escapeString($toSave->getUploaderID());
     $folder = $database->escapeString($toSave->getFolderID());
     $result = $database->updateTable('file', "uploaded='{$dateUploaded}', title='{$title}', mimeType='{$mimeType}', size={$size}, location='{$location}', nodeID={$nodeID}, uploader={$uploader}, folderID={$folder}", "fileID='{$id}'");
     if ($result === false) {
         return false;
     }
     return true;
 }
开发者ID:educask,项目名称:EducaskCore,代码行数:32,代码来源:FileSystemEngine.php

示例12: getGeneralLongDesc

 /**
  * Used instead of getLongDesc if there is no handler registered for file.
  *
  * @param File $file
  * @return string
  */
 static function getGeneralLongDesc($file)
 {
     return wfMessage('file-info')->sizeParams($file->getSize())->params($file->getMimeType())->parse();
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:10,代码来源:MediaHandler.php

示例13: checkExtensionCompatibility

 /**
  * Checks if file extensions are compatible
  *
  * @param $old File Old file
  * @param string $new New name
  *
  * @return bool|null
  */
 static function checkExtensionCompatibility(File $old, $new)
 {
     $oldMime = $old->getMimeType();
     $n = strrpos($new, '.');
     $newExt = self::normalizeExtension($n ? substr($new, $n + 1) : '');
     $mimeMagic = MimeMagic::singleton();
     return $mimeMagic->isMatchingExtension($newExt, $oldMime);
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:16,代码来源:File.php

示例14: afterInsertFile

 /**
  * Try to post new file to Geoserver.
  *
  * @param File $file The file.
  *
  * @return void.
  */
 public function afterInsertFile($file)
 {
     // Is the image a tiff?
     if ($file->getMimeType() == 'image/tiff') {
         // Get the active server.
         $server = $this->serversTable->getActiveServer();
         // Throw file at Geoserver.
         if ($server && _putFileToGeoserver($file, $server)) {
             // Get parent item and WMS.
             $item = $file->getItem();
             $wms = $this->servicesTable->findByItem($item);
             // If no WMS exists, create one for the file that
             // was just uploaded to Geoserver.
             if (!$wms) {
                 $this->servicesTable->createFromFileAndServer($file, $server);
             } else {
                 if ($wms->address == $server->getWmsAddress()) {
                     // If a WMS already exists and the address is the
                     // same as the address of the active server, append
                     // the new layer to the active layers list.
                     $wms->layers .= ',' . nlwms_layerName($server, $file);
                     $wms->save();
                 }
             }
         }
     }
 }
开发者ID:rameysar,项目名称:Omeka-Grinnell-RomanCiv,代码行数:34,代码来源:NeatlineMapsPlugin.php

示例15: getLegacyUrl

 /**
  * @param File $img
  * @param $width
  * @param $height
  * @return String
  */
 private function getLegacyUrl($img, $width, $height)
 {
     $issvg = false;
     $mime = strtolower($img->getMimeType());
     if ($mime == 'image/svg+xml' || $mime == 'image/svg') {
         $issvg = true;
     }
     $sPrefix = '';
     if (WikiaFileHelper::isVideoFile($img)) {
         // videos has different thumbnail markup
         $sPrefix = 'v,000000,';
     }
     $url = wfReplaceImageServer($img->getThumbUrl($sPrefix . $this->getCut($width, $height) . "-" . $img->getName() . ($issvg ? ".png" : "")));
     wfProfileOut(__METHOD__);
     return $url;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:22,代码来源:imageServing.class.php


注:本文中的File::getMimeType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。