PHP 클래스 UploadFile, thinksns

저자: Tiny
상속: extends File
파일 보기 프로젝트 열기: medz/thinksns-4 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$allowExts 留空不作后缀检查
$allowTypes 留空不做检查
$autoCheck
$autoSub 启用子目录保存文件
$dateFormat
$hashLevel
$hashType 例如可以是 md5_file sha1_file 等
$maxSize 上传文件的最大值
$saveName
$savePath 上传文件保存路径
$saveRule 必须是一个无需任何参数的函数名 可以使用自定义函数
$subType 子目录创建方式 可以使用hash date
$supportMulti 是否支持多文件上传
$thumb 使用对上传图片进行缩略图处理
$thumbFile 缩略图文件名
$thumbMaxHeight 缩略图最大高度
$thumbMaxWidth 缩略图最大宽度
$thumbPath 缩略图保存路径
$thumbPrefix 缩略图前缀
$thumbRemoveOrigin 是否移除原图
$thumbSuffix
$uploadReplace 存在同名是否覆盖
$zipImages 压缩图片文件上传

공개 메소드들

메소드 설명
__construct ( $maxSize = '', $allowExts = '', $allowTypes = '', $savePath = UPLOAD_PATH, $saveRule = '' ) +---------------------------------------------------------- 架构函数 +---------------------------------------------------------- +----------------------------------------------------------
getErrorMsg ( ) : string +---------------------------------------------------------- 取得最后一次错误信息 +---------------------------------------------------------- +----------------------------------------------------------
getUploadFileInfo ( ) : array +---------------------------------------------------------- 取得上传文件的信息 +---------------------------------------------------------- +----------------------------------------------------------
resetimg ( $savePath, $image_name, $save_path ) : string +---------------------------------------------------------- 重置图片大小尺寸 +---------------------------------------------------------- +----------------------------------------------------------
upload ( string $savePath = '' ) : string +---------------------------------------------------------- 上传文件 +---------------------------------------------------------- +----------------------------------------------------------

보호된 메소드들

메소드 설명
error ( string $errorNo ) +---------------------------------------------------------- 获取错误代码信息 +---------------------------------------------------------- +----------------------------------------------------------

비공개 메소드들

메소드 설명
check ( array $file ) : boolean +---------------------------------------------------------- 检查上传的文件 +---------------------------------------------------------- +----------------------------------------------------------
checkExt ( string $ext ) : boolean +---------------------------------------------------------- 检查上传的文件后缀是否合法 +---------------------------------------------------------- +----------------------------------------------------------
checkSize ( integer $size ) : boolean +---------------------------------------------------------- 检查文件大小是否合法 +---------------------------------------------------------- +----------------------------------------------------------
checkType ( string $type ) : boolean +---------------------------------------------------------- 检查上传的文件类型是否合法 +---------------------------------------------------------- +----------------------------------------------------------
checkUpload ( string $filename ) : boolean +---------------------------------------------------------- 检查文件是否非法提交 +---------------------------------------------------------- +----------------------------------------------------------
dealFiles ( array $files ) : array +---------------------------------------------------------- 转换上传文件数组变量为正确的方式 +---------------------------------------------------------- +----------------------------------------------------------
getExt ( string $filename ) : boolean +---------------------------------------------------------- 取得上传文件的后缀 +---------------------------------------------------------- +----------------------------------------------------------
getSaveName ( string $filename ) : string +---------------------------------------------------------- 根据上传文件命名规则取得保存文件名 +---------------------------------------------------------- +----------------------------------------------------------
getSubName ( array $file ) : string +---------------------------------------------------------- 获取子目录的名称 +---------------------------------------------------------- +----------------------------------------------------------
save ( $file ) : string +---------------------------------------------------------- 上传一个文件 +---------------------------------------------------------- +----------------------------------------------------------

메소드 상세

__construct() 공개 메소드

+---------------------------------------------------------- 架构函数 +---------------------------------------------------------- +----------------------------------------------------------
public __construct ( $maxSize = '', $allowExts = '', $allowTypes = '', $savePath = UPLOAD_PATH, $saveRule = '' )

error() 보호된 메소드

+---------------------------------------------------------- 获取错误代码信息 +---------------------------------------------------------- +----------------------------------------------------------
protected error ( string $errorNo )
$errorNo string 错误号码 +---------------------------------------------------------- +----------------------------------------------------------

getErrorMsg() 공개 메소드

+---------------------------------------------------------- 取得最后一次错误信息 +---------------------------------------------------------- +----------------------------------------------------------
public getErrorMsg ( ) : string
리턴 string +----------------------------------------------------------

getUploadFileInfo() 공개 메소드

+---------------------------------------------------------- 取得上传文件的信息 +---------------------------------------------------------- +----------------------------------------------------------
public getUploadFileInfo ( ) : array
리턴 array +----------------------------------------------------------

resetimg() 공개 메소드

+---------------------------------------------------------- 重置图片大小尺寸 +---------------------------------------------------------- +----------------------------------------------------------
public resetimg ( $savePath, $image_name, $save_path ) : string
리턴 string +----------------------------------------------------------

upload() 공개 메소드

+---------------------------------------------------------- 上传文件 +---------------------------------------------------------- +----------------------------------------------------------
public upload ( string $savePath = '' ) : string
$savePath string 上传文件保存路径 +----------------------------------------------------------
리턴 string +----------------------------------------------------------

프로퍼티 상세

$allowExts 공개적으로 프로퍼티

留空不作后缀检查
public $allowExts

$allowTypes 공개적으로 프로퍼티

留空不做检查
public $allowTypes

$autoCheck 공개적으로 프로퍼티

public $autoCheck

$autoSub 공개적으로 프로퍼티

启用子目录保存文件
public $autoSub

$dateFormat 공개적으로 프로퍼티

public $dateFormat

$hashLevel 공개적으로 프로퍼티

public $hashLevel

$hashType 공개적으로 프로퍼티

例如可以是 md5_file sha1_file 等
public $hashType

$maxSize 공개적으로 프로퍼티

上传文件的最大值
public $maxSize

$saveName 공개적으로 프로퍼티

public $saveName

$savePath 공개적으로 프로퍼티

上传文件保存路径
public $savePath

$saveRule 공개적으로 프로퍼티

必须是一个无需任何参数的函数名 可以使用自定义函数
public $saveRule

$subType 공개적으로 프로퍼티

子目录创建方式 可以使用hash date
public $subType

$supportMulti 공개적으로 프로퍼티

是否支持多文件上传
public $supportMulti

$thumb 공개적으로 프로퍼티

使用对上传图片进行缩略图处理
public $thumb

$thumbFile 공개적으로 프로퍼티

缩略图文件名
public $thumbFile

$thumbMaxHeight 공개적으로 프로퍼티

缩略图最大高度
public $thumbMaxHeight

$thumbMaxWidth 공개적으로 프로퍼티

缩略图最大宽度
public $thumbMaxWidth

$thumbPath 공개적으로 프로퍼티

缩略图保存路径
public $thumbPath

$thumbPrefix 공개적으로 프로퍼티

缩略图前缀
public $thumbPrefix

$thumbRemoveOrigin 공개적으로 프로퍼티

是否移除原图
public $thumbRemoveOrigin

$thumbSuffix 공개적으로 프로퍼티

public $thumbSuffix

$uploadReplace 공개적으로 프로퍼티

存在同名是否覆盖
public $uploadReplace

$zipImages 공개적으로 프로퍼티

压缩图片文件上传
public $zipImages