本文整理汇总了PHP中zmf::upDirs方法的典型用法代码示例。如果您正苦于以下问题:PHP zmf::upDirs方法的具体用法?PHP zmf::upDirs怎么用?PHP zmf::upDirs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zmf
的用法示例。
在下文中一共展示了zmf::upDirs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addPostImg
public function addPostImg()
{
$logid = zmf::filterInput($_GET['id']);
$uptype = zmf::filterInput($_GET['imgtype'], 't', 1);
if (!$uptype) {
$this->jsonOutPut(0, '不允许的分类');
}
if (!$logid) {
$logid = 0;
}
$ctime = time();
$dirs = zmf::upDirs($ctime, 'app', $uptype);
$origin = $dirs['origin'] . '/';
unset($dirs['origin']);
zmf::createUploadDir($origin);
$img = CUploadedFile::getInstanceByName('filedata');
if ($img->getHasError()) {
$this->jsonOutPut(0, '上传有误,请重试');
}
$ext = $img->getExtensionName();
$upExt = zmf::config("imgAllowTypes");
if (!preg_match('/^(' . str_replace('*.', '|', str_replace(';', '', $upExt)) . ')$/i', $ext)) {
$this->jsonOutPut(0, '上传文件扩展名必需为:' . $upExt);
}
$size = $img->getSize();
if ($size > zmf::config('imgMaxSize')) {
$this->jsonOutPut(0, '上传文件最大尺寸为:' . tools::formatBytes(zmf::config('imgMaxSize')));
}
$_imgInfo = getimagesize($_FILES["filedata"]["tmp_name"]);
if ($_imgInfo['0'] < zmf::config('imgMinWidth') or $_imgInfo[1] < zmf::config('imgMinHeight')) {
$this->jsonOutPut(0, "宽不能小于" . zmf::config('imgMinWidth') . "px<br/>高不能小于" . zmf::config('imgMinHeight') . "px");
}
$fileName = uniqid() . '.' . $ext;
// $_extra=self::getUpExtraUrl($ctime);
// $filePath=$_extra.'/'.$fileName;
if (move_uploaded_file($_FILES["filedata"]["tmp_name"], $origin . $fileName)) {
$uid = Yii::app()->user->id;
$uid = 1;
$data['uid'] = $uid;
$data['logid'] = $logid;
$data['filePath'] = $fileName;
$data['fileDesc'] = $fileName;
$data['classify'] = $uptype;
$data['covered'] = '0';
$data['cTime'] = $ctime;
$data['status'] = Posts::STATUS_DELED;
$model = new Attachments();
$model->attributes = $data;
if ($model->validate()) {
if (!$model->save()) {
$this->jsonOutPut(0, '写入数据库出错');
} else {
$attachid = $model->id;
}
} else {
$this->jsonOutPut(0, '数据验证错误');
}
$image = Yii::app()->image->load($origin . $fileName);
$_quality = zmf::config('imgQuality');
$quality = isset($quality) ? $quality : 100;
foreach ($dirs as $dk => $_dir) {
zmf::createUploadDir($_dir);
if ($_imgInfo[0] < $dk && $_imgInfo[1] < $dk) {
$image->resize($_imgInfo[0], $_imgInfo[1])->quality($quality);
} else {
$image->smart_resize($dk, ceil($dk * 0.75))->quality($quality);
}
$image->save($_dir . '/' . $fileName, false);
}
$_dir = zmf::upDirs($ctime, 'site', $uptype, '600');
$returnimg = $_dir . '/' . $fileName;
$data = array('imgsrc' => $returnimg, 'attachid' => $attachid);
$this->jsonOutPut(1, $data);
}
}