PHP Class UploadFile, thinksns

Author: Tiny
Inheritance: extends File
Exibir arquivo Open project: medz/thinksns-4 Class Usage Examples

Public Properties

Property Type Description
$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 压缩图片文件上传

Public Methods

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

Protected Methods

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

Private Methods

Method Description
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 +---------------------------------------------------------- 上传一个文件 +---------------------------------------------------------- +----------------------------------------------------------

Method Details

__construct() public method

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

error() protected method

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

getErrorMsg() public method

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

getUploadFileInfo() public method

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

resetimg() public method

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

upload() public method

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

Property Details

$allowExts public_oe property

留空不作后缀检查
public $allowExts

$allowTypes public_oe property

留空不做检查
public $allowTypes

$autoCheck public_oe property

public $autoCheck

$autoSub public_oe property

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

$dateFormat public_oe property

public $dateFormat

$hashLevel public_oe property

public $hashLevel

$hashType public_oe property

例如可以是 md5_file sha1_file 等
public $hashType

$maxSize public_oe property

上传文件的最大值
public $maxSize

$saveName public_oe property

public $saveName

$savePath public_oe property

上传文件保存路径
public $savePath

$saveRule public_oe property

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

$subType public_oe property

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

$supportMulti public_oe property

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

$thumb public_oe property

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

$thumbFile public_oe property

缩略图文件名
public $thumbFile

$thumbMaxHeight public_oe property

缩略图最大高度
public $thumbMaxHeight

$thumbMaxWidth public_oe property

缩略图最大宽度
public $thumbMaxWidth

$thumbPath public_oe property

缩略图保存路径
public $thumbPath

$thumbPrefix public_oe property

缩略图前缀
public $thumbPrefix

$thumbRemoveOrigin public_oe property

是否移除原图
public $thumbRemoveOrigin

$thumbSuffix public_oe property

public $thumbSuffix

$uploadReplace public_oe property

存在同名是否覆盖
public $uploadReplace

$zipImages public_oe property

压缩图片文件上传
public $zipImages