选择语言 :

Core_Upload

文件上传核心类

常量
Upload::ERR_OK integer 0
Upload::ERR_INI_SIZE integer 1
Upload::ERR_FORM_SIZE integer 2
Upload::ERR_PARTIAL integer 3
Upload::ERR_NO_FILE integer 4
Upload::ERR_NO_TMP_DIR integer 6
Upload::ERR_CANT_WRITE integer 7
Upload::ERR_EXTENSION integer 8
Upload::ERR_SAVE_FILE integer 11
Upload::TYPE_STORAGE string(7) "Storage"

API - Core_Upload

author
呼吸二氧化碳 jonwang@myqee.com
marlboro zxf1984@gmail.com
category
MyQEE
package
System
subpackage
Core
copyright
Copyright © 2008-2013 myqee.com
license
http://www.myqee.com/license.html

$this->__construct( )


Upload::factory( $file_key = null)

返回上传实例化对象

参数列表

参数 类型 描述 默认值
$file_key array $props null
返回值
  • Upload

$this->save( )

保存上传的文件

如果返回失败,可通过 Upload::error() 获取错误内容, Upload::errno() 获取错误编号

返回值
  • bool

$this->driver( )

返回当前上传驱动对象

若驱动为普通文件方式,则返回当前对象

返回值
  • Upload_Driver_Storage

$this->save_to_file( )

执行文件保存操作


$this->save_to_storage( )

通过Storage实现文件保存


$this->set_filename( $new_filename )

设置新文件名(包括文件后缀)

参数列表

参数 类型 描述 默认值
$new_filename string $new_filename
返回值
  • Upload

$this->check_is_upload_file( )

判断是否上传的文件

返回值
  • boolean

$this->check_real_mime( )

设置真实的文件类型

返回值
  • boolean|Core_Upload

$this->format_name( )

文件名安全过滤

返回值
  • Upload

$this->clean_filename( )

过滤文件名中的空格

返回值
  • Upload

$this->is_allowed_filesize( )

验证文件大小是否在允许范围内

返回值
  • bool

$this->is_allowed_filetype( )

文件是否被允许上传

判断后缀是否是允许范围 如果是图片后缀的文件会判断是否是真实图片 如果是严谨判断mimes,会检查文件mimes与后缀是否一致。如 example.jpg 为example.png改名而来,则会返回false

返回值
  • bool

$this->is_image( )

验证是否图片

返回值
  • bool

$this->set_image_properties( )

如果是图片则获取图片相关参数

返回值
  • Upload

Upload::set_error( $error_msg , $error_no = 0)

设置错误信息

参数列表

参数 类型 描述 默认值
$error_msg string $error_msg
$error_no number $error_no integer 0
返回值
  • Upload

Upload::errno( )

返回错误号

返回值
  • number

Upload::error( )

返回错误内容

返回值
  • string