From 687fa72199ad14b46f631dd9773ec12d3e71612d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 13 May 2021 18:44:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HttpServer/Http/File.php | 7 +++++-- System/Snowflake.php | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/HttpServer/Http/File.php b/HttpServer/Http/File.php index e422fefd..28d78746 100644 --- a/HttpServer/Http/File.php +++ b/HttpServer/Http/File.php @@ -18,6 +18,9 @@ class File public mixed $type = ''; public mixed $size = ''; + + private string $_content = ''; + private string $newName = ''; private array $errorInfo = [ 0 => 'UPLOAD_ERR_OK.', @@ -60,8 +63,8 @@ class File if (!file_exists($this->getTmpPath())) { throw new Exception('(' . $this->name . ')Failed to open stream: No such file or directory'); } - $param = ['tmp_name' => $this->getTmpPath()]; - $this->newName = Snowflake::rename($param); + + $this->newName = Snowflake::rename($this->getTmpPath()); return $this->newName; } diff --git a/System/Snowflake.php b/System/Snowflake.php index 42b33bc5..41520380 100644 --- a/System/Snowflake.php +++ b/System/Snowflake.php @@ -485,14 +485,14 @@ class Snowflake /** - * @param $tmp + * @param $tmp_name * @return string */ - public static function rename($tmp): string + public static function rename($tmp_name): string { - $hash = md5_file($tmp['tmp_name']); + $hash = md5_file($tmp_name); - $later = '.' . exif_imagetype($tmp['tmp_name']); + $later = '.' . exif_imagetype($tmp_name); $match = '/(\w{12})(\w{5})(\w{9})(\w{6})/'; $tmp = preg_replace($match, '$1-$2-$3-$4', $hash);