ouverture même si le fichier a changé de place
This commit is contained in:
		
							parent
							
								
									0bbc07311a
								
							
						
					
					
						commit
						0f71fa0918
					
				@ -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)) {
 | 
			
		||||
 | 
			
		||||
@ -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");
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user