Example #1
0
 /**
  * Upload file (delegated to storage object)
  * @return bool
  * @throws \Upload\Exception\UploadException If file does not validate
  */
 public function upload()
 {
     if ($this->validate() === false) {
         throw new \Upload\Exception\UploadException('File validation failed');
     }
     return $this->storage->upload($this);
 }
Example #2
0
 /**
  * Upload file (delegated to storage object)
  * @param  string $newName Give the file it a new name
  * @return bool
  * @throws \Upload\Exception\UploadException If file does not validate
  */
 public function upload($newName = null)
 {
     if ($this->validate() === false) {
         throw new \Upload\Exception\UploadException('File validation failed');
     }
     // Update the name, leaving out the extension
     if (is_string($newName)) {
         $this->name = pathinfo($newName, PATHINFO_FILENAME);
     }
     return $this->storage->upload($this, $newName);
 }