當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FileUtils::getFileExtension方法代碼示例

本文整理匯總了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;
 }
開發者ID:caidongyun,項目名稱:CS,代碼行數:50,代碼來源:SendAttachmentExAction.php

示例2: _getThumbTempFile

 private static function _getThumbTempFile($image)
 {
     $tempFileName = md5($image);
     $fileExt = FileUtils::getFileExtension($image, 'jpg');
     strlen($fileExt) > 5 && ($fileExt = 'jpg');
     $tempFileName .= '.' . $fileExt;
     return $tempFileName;
 }
開發者ID:caidongyun,項目名稱:CS,代碼行數:8,代碼來源:ImageUtils.php

示例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;
 }
開發者ID:demental,項目名稱:m,代碼行數:18,代碼來源:db.php

示例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));
 }
開發者ID:demental,項目名稱:m,代碼行數:10,代碼來源:T.php

示例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;
 }
開發者ID:caidongyun,項目名稱:CS,代碼行數:55,代碼來源:UIDiyController.php

示例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}));
 }
開發者ID:demental,項目名稱:m,代碼行數:21,代碼來源:db.php


注:本文中的FileUtils::getFileExtension方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。