public createFile ( |
||
$request | ||
$entity |
public function createFile(Request $request, Entity $entity, $entityName, $field)
{
$file = $request->files->get($field);
if ($file) {
$targetPath = $this->getPath($entityName, $entity, $field);
if (!file_exists($targetPath)) {
mkdir($targetPath, 0777, true);
}
$file->move($targetPath, $file->getClientOriginalName());
}
}