Ejemplo n.º 1
0
 /**
  * @ORM\PrePersist()
  * @ORM\PreUpdate()
  */
 public function preUpload()
 {
     if (null !== $this->file) {
         // do whatever you want to generate a unique name
         $filename = sha1(uniqid(mt_rand(), true));
         $this->path = $filename . '.' . $this->file->guessExtension();
         $this->size = filesize($this->file);
     }
 }
Ejemplo n.º 2
0
 public function preUpload()
 {
     if (null !== $this->file) {
         $this->path = sha1(uniqid(mt_rand(), true)) . '.' . $this->file->guessExtension();
     }
 }