Example #1
0
 public function upload()
 {
     // the file property can be empty if the field is not required
     if (null === $this->file) {
         return;
     }
     // we use the original file name here but you should
     // sanitize it at least to avoid any security issues
     // move takes the target directory and then the target filename to move to
     $this->file->move($this->getUploadRootDir(), $this->file->getClientOriginalName());
     // set the path property to the filename where you'ved saved the file
     $this->path = 'uploads/files/' . $this->getIssue()->getIssue() . '/' . $this->file->getClientOriginalName();
     // set the name property to the filename where you'ved saved the file
     $this->name = $this->file->getClientOriginalName();
     // clean up the file property as you won't need it anymore
     $this->file = null;
 }