1

I implement this functionality using this1 instruction but I don't know how to compare generated file name with uploaded files.

Edit:

I generate new file name using this code:

/**
 * Called before saving the entity
 * 
 * @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();
    }
}
Community
  • 1
  • 1

1 Answers1

0

I just use the PHP function file_exists to compare filenames.

Taher A. Ghaleb
  • 5,120
  • 5
  • 31
  • 44