From 0f71fa0918cf49380acd9b80e84ebc9616b55b86 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Mon, 18 Nov 2024 20:01:15 +0400 Subject: [PATCH] =?UTF-8?q?ouverture=20m=C3=AAme=20si=20le=20fichier=20a?= =?UTF-8?q?=20chang=C3=A9=20de=20place?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/file/csv/TAbstractReader.php | 2 +- src/file/web/Upload.php | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/file/csv/TAbstractReader.php b/src/file/csv/TAbstractReader.php index 64d2595..7c3dc3c 100644 --- a/src/file/csv/TAbstractReader.php +++ b/src/file/csv/TAbstractReader.php @@ -22,7 +22,7 @@ trait TAbstractReader { $params["ss_type"] = "xlsx"; } } - return new $class($reader->tmpName, $params); + return new $class($reader->getFile(), $params); } if (is_string($reader)) { diff --git a/src/file/web/Upload.php b/src/file/web/Upload.php index 991fc8a..763c944 100644 --- a/src/file/web/Upload.php +++ b/src/file/web/Upload.php @@ -4,6 +4,7 @@ namespace nur\sery\file\web; use nur\sery\cl; use nur\sery\file\FileReader; use nur\sery\os\path; +use nur\sery\os\sh; use nur\sery\php\coll\BaseArray; use nur\sery\ValueException; @@ -103,6 +104,7 @@ class Upload extends BaseArray { function moveTo(string $dest): bool { if ($this->file === null) { + sh::mkdirof($dest); $moved = move_uploaded_file($this->tmpName, $dest); if ($moved) $this->file = $dest; } else { @@ -111,8 +113,11 @@ class Upload extends BaseArray { return $moved; } - function getFile(): FileReader { - $file = $this->file ?? $this->tmpName; - return new FileReader($file, "r+b"); + function getFile(): string { + return $this->file ?? $this->tmpName; + } + + function getReader(): FileReader { + return new FileReader($this->getFile(), "r+b"); } }