文件上传类

2019-04-07 19:26:09于海丽

        if($this->overwrite == 0 && @file_exists($this->savepath.$this->savename))
        {
            $this->errno = 3;
            return false;
        }
        /** 如果有大小限制,检查文件是否超过限制 */
        if ($this->maxsize != 0 )
        {
            if ($this->file_size > $this->maxsize)
            {
                $this->errno = 5;
                return false;
            }
        }
        /** 文件上传 */
       if(!@copy($this->file, $this->savepath.$this->savename))
       {
            $this->errno = 4;
            return false;
       }
       /** 删除临时文件 */
       $this->destory();
       return true;
    }

    /**
     * 文件格式检查
     * @access protect
     */
    function validate_format()
    {

        if (!is_array($this->fileformat))  // 没有格式限制
            return true;
       $ext = strtolower($this->ext);
        reset($this->fileformat);
        while(list($var, $key) = each($this->fileformat))
        {
            if (strtolower($key) == $ext)
                return true;
        }
        reset($this->fileformat);
        return false;
相关文章 大家在看