Exemple #1
0
 public function uploadFichierDDC(\TRC\CoreBundle\ENtity\DDC\DDC $ddc, $type, $fichier, $nameuser = null)
 {
     $message = "";
     $code = 1;
     $chemin = $ddc->getDossier();
     $no = $fichier['name'];
     $ext = "";
     if (strlen($this->extension($no)) > 0) {
         $ext = "." . $this->extension($no);
     }
     $f = new Fichier();
     $f->setType($fichier['type']);
     $f->setNom($nameuser);
     if (is_null($nameuser)) {
         $f->setNom($this->nomSansExtension($no));
     }
     $f->setRs($type . date('dmYHis') . "." . $ext);
     $f->setNomoriginal($no);
     if ($type == "edp") {
         $f->setChemin($chemin . "epd/" . $f->getRs());
     } else {
         $f->setChemin($chemin . "fichiers/" . $f->getRs());
     }
     try {
         if (move_uploaded_file($fichier['tmp_name'], $f->getChemin())) {
             $message = "ok";
         }
     } catch (\Exception $e) {
         $message = "Erreur de téléchargement du fichier :: " . $no;
         // $e->getMessage();
         $code = 0;
     }
     return array("fichier" => $f, "message" => $message, "code" => $code);
 }
 /**
  * {@inheritDoc}
  */
 public function getDossier()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getDossier', []);
     return parent::getDossier();
 }