本文整理汇总了PHP中FileUtils::getFileExtension方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUtils::getFileExtension方法的具体用法?PHP FileUtils::getFileExtension怎么用?PHP FileUtils::getFileExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtils
的用法示例。
在下文中一共展示了FileUtils::getFileExtension方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _uploadAttach
/**
* 上传帖子图片(正常的附件目录)
*
* @param mixed $uid Description.
* @param mixed $allowValue Description.
*
* @access private
*
* @return mixed Value.
*/
private function _uploadAttach($uid, $allowValue)
{
global $_G;
$fileExtension = FileUtils::getFileExtension($_FILES['uploadFile']['name'][$allowValue], 'jpg');
$type = 'forum';
$extid = 0;
$forcename = '';
Yii::import('application.components.discuz.source.class.discuz.discuz_upload', true);
$upload = new Mobcent_upload();
$attach['extension'] = $fileExtension;
$attach['attachdir'] = $upload->get_target_dir($type, $extid);
$filename = $upload->get_target_filename($type, $extid, $forcename) . '.' . $attach['extension'];
$attach['attachment'] = $attach['attachdir'] . $filename;
$attach['target'] = getglobal('setting/attachdir') . './' . $type . '/' . $attach['attachment'];
$savePath = getglobal('setting/attachdir') . './' . $type . '/' . $attach['attachdir'];
if (!is_dir($savePath)) {
mkdir($savePath, 0777, true);
}
$remote = $width = $thumb = 0;
$res = array();
$saveName = $savePath . $filename;
if (move_uploaded_file($_FILES['uploadFile']['tmp_name'][$allowValue], $saveName)) {
$aid = getattachnewaid($uid);
$img_info = getimagesize($attach['target']);
$size = filesize($attach['target']);
$insert = array('aid' => $aid, 'dateline' => $_G['timestamp'], 'filename' => $filename, 'filesize' => $size, 'attachment' => $attach['attachment'], 'isimage' => 1, 'uid' => $uid, 'thumb' => $thumb, 'remote' => $remote, 'width' => $img_info[0]);
C::t('forum_attachment_unused')->insert($insert);
// 添加水印
Yii::import('application.components.discuz.source.class.class_image', true);
$image = new Mobcent_Image();
if ($image->param['watermarkstatus']['forum'] > 0) {
$image->makeWatermark($attach['target'], '', 'forum');
}
$path_url = ImageUtils::getAttachUrl() . '/' . $type . '/' . $attach['attachment'];
ImageUtils::getThumbImageEx($path_url, 10, false, false, true);
$res['id'] = $aid;
$res['urlName'] = $path_url;
}
return $res;
}
示例2: _getThumbTempFile
private static function _getThumbTempFile($image)
{
$tempFileName = md5($image);
$fileExt = FileUtils::getFileExtension($image, 'jpg');
strlen($fileExt) > 5 && ($fileExt = 'jpg');
$tempFileName .= '.' . $fileExt;
return $tempFileName;
}
示例3: _upFile
/**
* Helper method to store the file
*/
protected function _upFile($obj, $field, $relativePathFromUploadFolder, $prefix = null)
{
if (is_null($prefix)) {
$prefix = $obj->tableName();
}
if (is_uploaded_file($_FILES[$field]['tmp_name'])) {
$ext = FileUtils::getFileExtension($_FILES[$field]['name']);
$name = $prefix . "." . $ext;
$destination = IMAGES_UPLOAD_FOLDER . $relativePathFromUploadFolder . '/' . $name;
if (move_uploaded_file($_FILES[$field]["tmp_name"], $destination) && chmod($destination, 0644)) {
return $name;
}
}
return false;
}
示例4: getStringsFromfile
private function getStringsFromfile($file, &$lngtb)
{
$extension = FileUtils::getFileExtension($file);
$method = 'getStringsFrom' . $extension;
if (!method_exists($this, $method)) {
return;
}
$reflectionMethod = new ReflectionMethod('T', $method);
$reflectionMethod->invokeArgs($this, array($file, &$lngtb));
}
示例5: checkUpload
/**
* 检测上传相关项
*
* @param mixed $res 初始化数组.
* @param mixed $file 上传的单个文件数组信息.
*
* @return mixed array.
*/
public function checkUpload($res, $file)
{
// 文件上传失败,捕获错误代码
if ($file['error']) {
$res['errCode'] = 0;
$res['errMsg'] = self::error($file['error']);
return $res;
}
// 无效上传
$file['name'] = strip_tags($file['name']);
if (empty($file['name'])) {
$res['errCode'] = 0;
$res['errMsg'] = '未知上传错误!';
return $res;
}
if (!is_uploaded_file($file['tmp_name'])) {
$res['errCode'] = 0;
$res['errMsg'] = '非法上传文件';
return $res;
}
// 检查文件大小
$maxSize = 2000000;
if ($file['size'] > $maxSize || $file['size'] == 0) {
$res['errCode'] = 0;
$res['errMsg'] = '上传文件大小不符!';
return $res;
}
// 检查文件Mime类型
$mime = $file['type'];
$allowMime = array('image/png', 'image/jpeg');
if (!in_array(strtolower($mime), $allowMime)) {
$res['errCode'] = 0;
$res['errMsg'] = '上传文件MIME类型不允许!';
return $res;
}
// 检查文件后缀
$ext = FileUtils::getFileExtension($file['name'], 'jpg');
$allowExt = array('jpg', 'png', 'jpeg');
if (!in_array(strtolower($ext), $allowExt)) {
$res['errCode'] = 0;
$res['errMsg'] = '上传文件后缀不允许!';
return $res;
}
// 通过检测
$res['errCode'] = 1;
return $res;
}
示例6: getFileFormat
public function getFileFormat()
{
$args = func_get_args();
if (is_a($args[0], 'DB_DataObject')) {
$obj = $args[0];
$field = null;
} else {
$obj = $args[1];
$field = $args[0];
}
$info = $obj->_getPluginsDef();
$info = $info['upload'];
if (is_null($field)) {
$field = array_keys($info);
$field = $field[0];
$info = array_shift($info);
} else {
$info = $info[$field];
}
return self::returnStatus(FileUtils::getFileExtension($obj->{$field}));
}