选择语言 :

 Core_Upload::save

保存上传的文件

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

bool Core_Upload::save( )
返回值
  • bool
File: ./core/classes/upload.class.php
public function save()
{
    try
    {
        // 判断是否上传文件
        $this->check_is_upload_file();

        // 检查真实文件类型
        $this->check_real_mime();

        // 整理文件名
        $this->format_name();

        if (!$this->is_allowed_filesize())
        {
            throw new Exception('Upload invalid filesize.', UPLOAD::ERR_FORM_SIZE);
        }

        // 设置图片相关参数
        $this->set_image_properties();


        // 保存上传文件
        if ($this->config['driver'] == 'default')
        {
            $this->save_to_file();

            return true;
        }
        else
        {
            // 通过扩展驱动来实现文件保存
            $this->save_to_storage();
        }
    }
    catch (Exception $e)
    {
        $this->set_error($e->getMessage(), $e->getCode());
        return false;
    }
}