Example #1
0
 /**
  * Upload
  *
  * @param  \Upload\FileInfoInterface $file The file object to upload
  * @throws \Upload\Exception               If overwrite is false and file already exists
  * @throws \Upload\Exception               If error moving file to destination
  */
 public function upload(\Upload\FileInfoInterface $fileInfo)
 {
     $destinationFile = $this->directory . $fileInfo->getNameWithExtension();
     if ($this->overwrite === false && file_exists($destinationFile) === true) {
         throw new \Upload\Exception('File already exists', $fileInfo);
     }
     if ($this->moveUploadedFile($fileInfo->getPathname(), $destinationFile) === false) {
         throw new \Upload\Exception('File could not be moved to final destination.', $fileInfo);
     }
 }