You are here

private function Uploader::getFullName in UEditor - 百度编辑器 7.2

Same name and namespace in other branches
  1. 7.3 includes/Uploader.class.inc \Uploader::getFullName()

重命名文件

Return value

string

3 calls to Uploader::getFullName()
Uploader::saveRemote in includes/Uploader.class.inc
拉取远程图片
Uploader::upBase64 in includes/Uploader.class.inc
处理base64编码的图片上传
Uploader::upFile in includes/Uploader.class.inc
上传文件的主处理方法

File

includes/Uploader.class.inc, line 358

Class

Uploader
Created by JetBrains PhpStorm. User: taoqili Date: 12-7-18 Time: 上午11: 32 UEditor编辑器通用上传类

Code

private function getFullName() {

  //替换日期事件
  $t = time();
  $d = explode('-', date("Y-y-m-d-H-i-s"));
  $format = $this->config["pathFormat"];
  $format = str_replace("{yyyy}", $d[0], $format);
  $format = str_replace("{yy}", $d[1], $format);
  $format = str_replace("{mm}", $d[2], $format);
  $format = str_replace("{dd}", $d[3], $format);
  $format = str_replace("{hh}", $d[4], $format);
  $format = str_replace("{ii}", $d[5], $format);
  $format = str_replace("{ss}", $d[6], $format);
  $format = str_replace("{time}", $t, $format);

  //过滤文件名的非法自负,并替换文件名
  $oriName = substr($this->oriName, 0, strrpos($this->oriName, '.'));
  $oriName = preg_replace("/[\\|\\?\"\\<\\>\\/\\*\\\\]+/", '', $oriName);
  $format = str_replace("{filename}", $oriName, $format);

  //替换随机字符串
  $randNum = rand(1, 10000000000) . rand(1, 10000000000);
  if (preg_match("/\\{rand\\:([\\d]*)\\}/i", $format, $matches)) {
    $format = preg_replace("/\\{rand\\:[\\d]*\\}/i", substr($randNum, 0, $matches[1]), $format);
  }

  //用Transliteration生成文件名
  if (strpos($format, '{transliteration_filename}')) {
    if (module_exists('transliteration') && function_exists('transliteration_clean_filename')) {
      $format = str_replace("{transliteration_filename}", transliteration_clean_filename($oriName), $format);
    }
  }
  $ext = $this
    ->getFileExt();
  return $format . $ext;
}