本文整理汇总了PHP中UploadHandler::trim_file_name方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadHandler::trim_file_name方法的具体用法?PHP UploadHandler::trim_file_name怎么用?PHP UploadHandler::trim_file_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UploadHandler
的用法示例。
在下文中一共展示了UploadHandler::trim_file_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: trim_file_name
/**
* Transform trimmed filename to filesystem-friendly string
*
* @param $file_path
* @param $name
* @param $size
* @param $type
* @param $error
* @param $index
* @param $content_range
*
* @return string
*/
protected function trim_file_name($file_path, $name, $size, $type, $error, $index, $content_range)
{
$trimmedName = parent::trim_file_name($file_path, $name, $size, $type, $error, $index, $content_range);
$fileNameParts = pathinfo($trimmedName);
$slugOfName = $this->slug($fileNameParts['filename']);
$resultFileName = $slugOfName . '.' . $fileNameParts['extension'];
$this->setUploadedFileName($resultFileName);
return $resultFileName;
}
示例2: trim_file_name
protected function trim_file_name($name, $type, $index, $content_range)
{
$name = parent::trim_file_name($name, $type, $index, $content_range);
if (isset($this->options['filename']) && (!isset($this->options['unique_filename']) || $this->options['unique_filename'] == false)) {
$name = $this->options['filename'] . strtolower(strrchr($name, '.'));
} else {
if (isset($this->options['unique_filename']) && $this->options['unique_filename']) {
$tmp = explode(".", $name);
$name = md5(uniqid(rand(), TRUE)) . "." . $tmp[count($tmp) - 1];
}
}
return $name;
}
示例3: trim_file_name
protected function trim_file_name($file_path, $name, $size, $type, $error, $index, $content_range)
{
$name = parent::trim_file_name($file_path, $name, $size, $type, $error, $index, $content_range);
return $this->_generateRandomFileName($name);
}