检查文件大小是否合格
@param $filename
767430
protected function checkFileSize($filename) {

        if ( filesize($filename) > $this->config['max_size'] ) {
            $this->errNum = 1;
        }

        //如果是图片还要检查图片的宽度和高度是否超标
        $size = getimagesize($filename);
        if ( $size != false ) {

            $this->fileInfo['is_image'] = 1;
            if ( ($this->config['max_width'] > 0 && $size[0] > $this->config['max_width'])
                || ($this->config['max_height'] > 0 && $size[1] > $this->config['max_height']) )  {
                $this->errNum = 9;
            }
            $this->fileInfo['image_width'] = $size[0];
            $this->fileInfo['image_height'] = $size[1];

        } else {

            $this->fileInfo['is_image'] = 0;

        }

	}
869157
public function containsFile( $fileName )
	{
		if( !$this->numFiles )
			return FALSE;
		foreach( $this->files as $key => $information )
			if( $information['name'] == $fileName )
				return TRUE;
	}
138476
private function createFileDirIfNotExists(string $filename): bool
    {
        $pathinfo = pathinfo($filename);
        if (isset($pathinfo['dirname']) && $pathinfo['dirname'] !== '.') {
            if (is_dir($pathinfo['dirname'])) {
                return true;
            } elseif (is_file($pathinfo['dirname'])) {
                return false;
            } else {
                return $this->createDirIfNotExists($pathinfo['dirname']);
            }
        }
        return false;
    }
803187
public static function removeExtension($fileName) {
		$ext = strrchr($fileName, '.');
		if($ext !== false) {
			$fileName = substr($fileName, 0, -strlen($ext));
		}
		return $fileName;
	}
820174
public function attachFile($file, $fileName = null)
    {
        if (gettype($file) == 'resource') {
            $this->file = ['fileName' => $fileName, 'fileContent' => $file];
        } else {
            $this->file = ['fileName' => $fileName, 'fileContent' => fopen($file, 'r')];
        }
    }
1193926
public function writeFixedSizeFile($fileName, $fileSize)
    {
        $this->createFile($fileName, '');
        $this->inCurrentDir(function() use ($fileName, $fileSize) {
            $fh = fopen($fileName, 'w');
            fseek($fh, $fileSize - 1);
            fwrite($fh, "\0", 1);
            fclose($fh);
        });
    }
386346
function _size($filename)
    {
        $result = $this->_stat($filename, NET_SFTP_LSTAT);
        if ($result === false) {
            return false;
        }
        return isset($result['size']) ? $result['size'] : -1;
    }
969891
public function setFilename($filename)
    {
        $this->throwExceptionIfProtected();

        $pathInfo = UnicodeFunctions::pathinfo($filename);
        $extension = (isset($pathInfo['extension']) ? '.' . strtolower($pathInfo['extension']) : '');
        $this->filename = $pathInfo['filename'] . $extension;
        $this->mediaType = Utility\MediaTypes::getMediaTypeFromFilename($this->filename);
    }
1189922
private function normalizeFileName($fileName)
    {
        if (!is_array($fileName)) {
            return $fileName;
        }

        return isset($fileName['filename']) ? $fileName['filename']
            : isset($fileName['file']) ? $fileName['file'] : ''
        ;
    }
276432
public function setFileName($fileName = null) {
		if (empty($fileName)) {
			return false;
		}

		$this->_fileName = (string)$fileName;

		return true;
	}
851856
public function setFilename($filename = null)
    {
        $this->filename = $filename;

        $sub_dir = '';
        $sub_dir .= substr($filename, 0, 2).DIRECTORY_SEPARATOR;
        $sub_dir .= substr($filename, 2, 2).DIRECTORY_SEPARATOR;
        $sub_dir .= substr($filename, 4, 2);

        $this->setSubDir($sub_dir);
        $this->setPath($sub_dir.DIRECTORY_SEPARATOR.$filename);

        return $this;
    }
1102914
public function useFilename($filename)
    {
        $this->filename = $this->sanitizeFilename($filename);
        $this->hash_filename = false;

        return $this;
    }
922747
public function checkFileSize($fileName, $fileSize)
    {
        $this->inCurrentDir(function() use ($fileName, $fileSize) {
            if (filesize($fileName) !== $fileSize) {
                throw new ExpectationException("Size of $fileName not equals $fileSize");
            }
        });
    }
1330582
private function size($filename)
    {
        if ($this->isSFTP()) {
            $size = (int)@$this->ftp->size($filename);
        } else {
            $size = @ftp_size($this->ftp, $filename);
        }
        if ($size > 0) {
            return $size;
        }
        $this->fail("couldn't get the file size for {$filename}");
    }
1197328
protected function checkFileExtension($filename)
    {
        $extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
        if (!in_array($extension, static::FILE_EXTENSION)) {
            throw new BadRequestException(
                "Unsupported file type. Supported types are " . implode(', ', static::FILE_EXTENSION)
            );
        }
        $this->extension = $extension;
    }
633951
function size($filename)
    {
        if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) {
            return false;
        }

        $filename = $this->_realpath($filename);
        if ($filename === false) {
            return false;
        }

        return $this->_size($filename);
    }
1012052
protected function extensionOfName($fileName)
    {
        if (mb_strpos($fileName, '.') === false) {
            return mb_strtolower($fileName);
        }

        return mb_strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
    }