public function create(UploadedFile $file, $fileName = null, $path = null) { $fh = new FileHandler(); $absolutePath = $fh->move($file, $fileName, $path); $media = $this->saveToDB($file, $absolutePath); return $media; }
/** * If the foam field is a file, * it will place the file in the position * then change the $formInputs field, change the value from a upload file to a url link which map to the file location * if the foam field is not uploadfile, then it will just return the $formInputs array with not modification. * * @param $value * @param $formInputs * @param $name * * @return mixed */ private function moveIfFileUploaded($name, $uploadFile, $formInputs) { if ($uploadFile instanceof UploadedFile) { $fh = new FileHandler(); $formInputs[$name] = $fh->move($uploadFile); } return $formInputs; }