本文整理汇总了PHP中FileManager::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP FileManager::factory方法的具体用法?PHP FileManager::factory怎么用?PHP FileManager::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileManager
的用法示例。
在下文中一共展示了FileManager::factory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createFileBySentData
/**
* Create \Model\File instance on the basis of sent form data.
*
* @access private
* @param array $dataBatch
* @return \Model\File
* @since 1.0.0-alpha
* @version 1.0.0-alpha
*/
private function createFileBySentData($dataBatch)
{
$oLoggedUser = User::getLoggedUser();
$aExplodedFile = explode('.', $dataBatch['name']);
$sPath = PATH_TEMP . 'form_files' . DS . $this->getFormObject()->getName() . DS . $this->getName();
$sPath = str_replace([PATH_PUBLIC, DS], ['', '/'], $sPath);
$oFileManager = \FileManager::factory();
$oFileManager->prepareDir($sPath);
$oFileManager->parseFileData($dataBatch, $aExplodedFile[0]);
$oFileManager->upload($sPath, FileManager::UPLOAD_SAVE_BOTH);
$oFile = new \Model\File();
$oFile->setPath($sPath);
$oFile->setSize($dataBatch['size']);
$oFile->setExt($oFileManager->getExt());
$oFile->setName($oFileManager->getName());
$oFile->setMime($oFileManager->getMime());
$oFile->setStatus(0);
if ($oLoggedUser !== NULL) {
$oFile->setAuthor($oLoggedUser);
}
return $oFile;
}
示例2: __construct
/**
* Create image from path
*
* @access public
* @param string $sPath path to image
* @param integer $sType image type (if null, get by extension)
* @return \Image Image class
* @since 1.0.0
* @version 1.1.9, 2014-12-14
*/
public function __construct($sPath = FALSE, $sType = FALSE)
{
if ($sPath) {
$sPath = str_replace(DIRECTORY_SEPARATOR, '/', $sPath);
if (!file_exists($sPath)) {
throw new \Plethora\Exception\Fatal\Image('Image with path "' . $sPath . '" does not exists!');
}
$this->oImageFile = \FileManager::factory()->prepareFileByPath($sPath);
if (!$sType) {
$this->sExtension = $this->getImageFileObject()->getExt();
$this->sType = static::extensionToImageType($this->sExtension);
} else {
$this->sExtension = static::imageTypeToExtension($sType);
$this->sType = $sType;
}
$this->sContentType = static::extensionToContentType($this->sExtension);
switch ($this->sType) {
case self::PNG:
$this->rImage = imagecreatefrompng($sPath);
break;
case self::JPEG:
$this->rImage = imagecreatefromjpeg($sPath);
break;
case self::GIF:
$this->rImage = imagecreatefromgif($sPath);
break;
case self::GD:
$this->rImage = imagecreatefromgd($sPath);
break;
case self::GD2:
$this->rImage = imagecreatefromgd2($sPath);
break;
default:
throw new \Plethora\Exception\Fatal('Unknown image type!');
}
if (!empty($this->rImage)) {
$this->iWidth = imagesx($this->rImage);
$this->iHeight = imagesy($this->rImage);
}
}
return $this;
}