/**
  * Constructs the class with the minimal requeriments to upload a single file sucessfuly
  * @param array $uploadedFile the uploaded file $_FILES['file']
  * @param string $targetDirectory if the given dictory do not exists, the class tries to create
  */
 public function __construct(array $uploadedFile, $targetDirectory)
 {
     $this->uploadedFile = new UploadedFile($uploadedFile);
     $this->upload = new Upload($this->uploadedFile);
     $this->upload->setTargetDirectory($targetDirectory);
     $this->upload->setFileNewName($this->uploadedFile->getFileName());
 }
Beispiel #2
0
 public function validate()
 {
     if (count($this->allowedMimeTypes) == 0) {
         return true;
     }
     if (!in_array($this->uploadedFile->getFileMimeType(), $this->allowedMimeTypes)) {
         throw new \OutOfBoundsException(sprintf('O tipo do arquivo "%s" não é permitido pelo sistema', $this->uploadedFile->getFileMimeType()));
     }
     return true;
 }