本文整理汇总了PHP中Filesystem::mkdirs方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::mkdirs方法的具体用法?PHP Filesystem::mkdirs怎么用?PHP Filesystem::mkdirs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filesystem
的用法示例。
在下文中一共展示了Filesystem::mkdirs方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processAvatar
public static function processAvatar($model, $source, $type = "artist")
{
try {
$fileSystem = new Filesystem();
$alowSize = Yii::app()->params['imageSize'];
$maxSize = max($alowSize);
$folderMax = "s0";
foreach ($alowSize as $folder => $size) {
// Create folder by ID
$fileSystem->mkdirs($model->getAvatarPath($model->id, $folder, true));
@chmod($model->getAvatarPath($model->id, $folder, true), 0755);
// Get link file by ID
$savePath[$folder] = $model->getAvatarPath($model->id, $folder);
if ($size == $maxSize) {
$folderMax = $folder;
}
}
// Delete file if exists
if (file_exists($savePath[$folder])) {
$fileSystem->remove($savePath);
}
if (file_exists($source)) {
list($width, $height) = getimagesize($source);
$imgCrop = new ImageCrop($source, 0, 0, $width, $height);
// aspect ratio for image size
$aspectRatioW = $aspectRatioH = 1;
if ($type == "video") {
$videoAspectRatio = Yii::app()->params['videoResolutionRate'];
list($aspectRatioW, $aspectRatioH) = explode(":", $videoAspectRatio);
}
$res = array();
foreach ($savePath as $k => $v) {
$desWidth = $alowSize[$k];
$desHeight = round($alowSize[$k] * intval($aspectRatioH) / intval($aspectRatioW));
if (file_exists($v) && is_file($v)) {
@unlink($v);
}
if ($width > 4000) {
self::ImageCropPro($v, $source, $desWidth, $desHeight, 70);
} else {
if ($k == $folderMax) {
$imgCrop->resizeRatio($v, $desWidth, $desHeight, 70);
} else {
$imgCrop->resizeCrop($v, $desWidth, $desHeight, 70);
}
}
}
if ($type != "video") {
$fileSystem->remove($source);
}
}
} catch (Exception $e) {
$error = $e->getMessage();
}
}
示例2: generalStoragePath
public static function generalStoragePath($objId, $fileType = 'jpg', $storage, $isUrl = false)
{
$year = date('Y');
$month = date('m');
$day = date('d');
$sep = $isUrl ? '/' : DS;
$exPath = $year . $sep . $month . $sep . $day;
$filePath = $storage . $sep . $exPath;
$fileSystem = new Filesystem();
$res = $fileSystem->mkdirs($filePath, '0755');
return $filePath . $sep . $objId . '.' . $fileType;
}
示例3: processAvatar
public static function processAvatar($id, $source, $type = "blog")
{
$fileSystem = new Filesystem();
$alowSize = Yii::app()->params['imageSize']["{$type}"];
$maxSize = max($alowSize);
$folderMax = "s0";
$pathDir = Yii::app()->params[$type . '_path'];
foreach ($alowSize as $folder => $size) {
// Create folder by ID
$avatarPath = self::getAvatarPath($id, $folder, true, $pathDir);
$fileSystem->mkdirs($avatarPath);
@chmod($avatarPath, 0777);
// Get link file by ID
$savePath[$folder] = self::getAvatarPath($id, $folder, false, $pathDir);
if ($size == $maxSize) {
$folderMax = $folder;
}
}
// Delete file if exists
if (file_exists($savePath[$folder])) {
$fileSystem->remove($savePath);
}
if (file_exists($source)) {
list($width, $height) = getimagesize($source);
$imgCrop = new ImageCrop($source, 0, 0, $width, $height);
// aspect ratio for image size
$aspectRatioW = $aspectRatioH = 1;
foreach ($savePath as $k => $v) {
$desWidth = $alowSize[$k];
$desHeight = round($alowSize[$k] * intval($aspectRatioH) / intval($aspectRatioW));
if (file_exists($v) && is_file($v)) {
@unlink($v);
}
if ($k == $folderMax) {
$imgCrop->resizeRatio($v, $desWidth, $desHeight, 100);
} else {
$imgCrop->resizeCrop($v, $desWidth, $desHeight, 100);
}
}
//remove file source
$fileSystem->remove($source);
}
}
示例4: createImage
function createImage($model, $image_path)
{
if (file_exists($image_path)) {
$fileSystem = new Filesystem();
$s0Path = $model->getAvatarPath($model->id, "s0", false);
// Origin
$s1Path = $model->getAvatarPath($model->id, "s1", false);
// Resize
$s2Path = $model->getAvatarPath($model->id, "s2", false);
// Thumb
$fileSystem->mkdirs(dirname($s0Path));
$fileSystem->mkdirs(dirname($s1Path));
$fileSystem->mkdirs(dirname($s2Path));
list($width, $height) = getimagesize($image_path);
$imgCrop = new ImageCrop($image_path, 0, 0, $width, $height);
$fileSystem->copy($image_path, $s0Path);
$imgCrop->resizeFix($s1Path, 690, 250);
$imgCrop->resizeFix($s2Path, 100, 100);
$fileSystem->remove($image_path);
}
}