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


PHP AppHelper::getByteValueFromPhpSizeString方法代码示例

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


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

示例1: getMaxUploadSize

 /**
  * Return max upload size in bytes.
  *
  * @return int
  */
 public function getMaxUploadSize()
 {
     $maxUpload = AppHelper::getByteValueFromPhpSizeString(ini_get('upload_max_filesize'));
     $maxPost = AppHelper::getByteValueFromPhpSizeString(ini_get('post_max_size'));
     $memoryLimit = AppHelper::getByteValueFromPhpSizeString(ini_get('memory_limit'));
     $uploadInBytes = min($maxUpload, $maxPost);
     if ($memoryLimit > 0) {
         $uploadInBytes = min($uploadInBytes, $memoryLimit);
     }
     $configLimit = (int) craft()->config->get('maxUploadFileSize');
     if ($configLimit) {
         $uploadInBytes = min($uploadInBytes, $configLimit);
     }
     return $uploadInBytes;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:20,代码来源:AppVariable.php

示例2: checkMemoryForImage

 /**
  * Determines if there is enough memory to process this image.
  *
  * The code was adapted from http://www.php.net/manual/en/function.imagecreatefromjpeg.php#64155. It will first
  * attempt to do it with available memory. If that fails, Craft will bump the memory to amount defined by the
  * [phpMaxMemoryLimit](http://buildwithcraft.com/docs/config-settings#phpMaxMemoryLimit) config setting, then try again.
  *
  * @param string $filePath The path to the image file.
  * @param bool   $toTheMax If set to true, will set the PHP memory to the config setting phpMaxMemoryLimit.
  *
  * @return bool
  */
 public function checkMemoryForImage($filePath, $toTheMax = false)
 {
     if (!function_exists('memory_get_usage')) {
         return false;
     }
     if ($toTheMax) {
         // Turn it up to 11.
         craft()->config->maxPowerCaptain();
     }
     // Find out how much memory this image is going to need.
     $imageInfo = getimagesize($filePath);
     $K64 = 65536;
     $tweakFactor = 1.7;
     $bits = isset($imageInfo['bits']) ? $imageInfo['bits'] : 8;
     $channels = isset($imageInfo['channels']) ? $imageInfo['channels'] : 4;
     $memoryNeeded = round(($imageInfo[0] * $imageInfo[1] * $bits * $channels / 8 + $K64) * $tweakFactor);
     $memoryLimit = AppHelper::getByteValueFromPhpSizeString(ini_get('memory_limit'));
     if (memory_get_usage() + $memoryNeeded < $memoryLimit) {
         return true;
     }
     if (!$toTheMax) {
         return $this->checkMemoryForImage($filePath, true);
     }
     // Oh well, we tried.
     return false;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:38,代码来源:ImagesService.php


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