= 1024){ $size = $size / 1024; $size = round($size,1); $name = $size.' MB'; } } return $name; } //缩略图函数 function thumbnail($img){ //返回路径 $dir = dirname($img['path']); $thumbnail_name = $dir.'/'.$img['imgid'].'_thumb'.$img['ext']; //缩略图完整地址 $fullpath = FCPATH.$thumbnail_name; //echo $fullpath; //判断缩略图是否存在 if(is_file($fullpath)){ return $thumbnail_name; } //$thumbnail_name = $dir.$name.'_thumb'; //返回缩略图地址,不带文件名 //返回原图 else{ return $img['path']; } } //生成4位随机数,方法来自:https://blog.csdn.net/happy_jijiawei/article/details/50581094 function GetRandStr($len) { $chars = array( "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ); $charsLen = count($chars) - 1; shuffle($chars); $output = ""; for ($i=0; $i<$len; $i++) { $output .= $chars[mt_rand(0, $charsLen)]; } return $output; } ?>