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"); } }