本文整理匯總了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);
}