/** * @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); } }
public function preUpload() { if (null !== $this->file) { $this->path = sha1(uniqid(mt_rand(), true)) . '.' . $this->file->guessExtension(); } }