SubirArchivo.php 448 Bytes
<?php

namespace UBV\SurUbvBundle;

use Symfony\Component\HttpFoundation\File\UploadedFile;

class SubirArchivo
{
  
  private $targetDir;

  public function __construct($targetDir)
  {
      $this->targetDir = $targetDir;
  }

  public function upload(UploadedFile $file)
  {
      $fileName = md5(uniqid()).'.'.$file->guessExtension();

      $file->move($this->targetDir.'Documentos/Estudiantes/', $fileName);

      return $fileName;
  }
  

}