예제 #1
0
 /**
  * @throws \Bluz\Request\RequestException
  */
 public function renameFileName()
 {
     $fileName = strtolower($this->file->getName());
     // Prepare filename
     $fileName = preg_replace('/[ _;:]+/i', '-', $fileName);
     $fileName = preg_replace('/[-]+/i', '-', $fileName);
     $fileName = preg_replace('/[^a-z0-9.-]+/i', '', $fileName);
     // If name is wrong
     if (empty($fileName)) {
         $fileName = date('Y-m-d-His');
     }
     // If file already exists, increment name
     $originFileName = $fileName;
     $counter = 0;
     while (file_exists($this->uploadPath . $fileName . '.' . $this->file->getExtension())) {
         $counter++;
         $fileName = $originFileName . '-' . $counter;
     }
     // Setup new name and move to user directory
     $this->file->setName($fileName);
     $this->file->moveTo($this->uploadPath);
 }
예제 #2
0
 /**
  * Test get size
  */
 public function testGetSize()
 {
     $result = $this->httpFile->getSize();
     $this->assertEquals(filesize($this->path), $result);
 }
예제 #3
0
 /**
  * Construct of TestFile
  * @param array $data
  * @throws \Bluz\Request\RequestException
  */
 public function __construct($data)
 {
     parent::__construct($data);
 }