public function uploadEvidenceFile(IncidentInterface $incident) { // if (null === $incident->getEvidenceFile()) { // return; // } // if there is an error when moving the file, an exception will // be automatically thrown by move(). This will properly prevent // the entity from being persisted to the database on error $uploadDir = $this->getUploadDirectory() . $incident->getEvidenceSubDirectory(); if (!file_exists($uploadDir)) { if (!mkdir($uploadDir, 0777, true)) { die('Failed to create folders...'); } } if ($incident->getEvidenceFile()) { $incident->getEvidenceFile()->move($uploadDir, $incident->getEvidenceFilePath()); } // check if we have an old image // if ($incident->getEvidenceFileTemp()) { // // delete the old image // unlink($this->getUploadDirectory() . $incident->getEvidenceFileTemp()); // // clear the temp image path // $incident->setEvidenceFileTemp(null); // } }