public function uploadProfileImage(Request $request, $id)
    {

        if (!$id) {
            throw $this->createNotFoundException('Unable to upload.');
        }

        if ($id != $this->get('security.token_storage')->getToken()->getUser()->getId()) {
            throw $this->createNotFoundException('Can not upload anything to a profile that is not their own.');
        }
        
        $em = $this->container->get('doctrine')->getManager();
        $entity = $this->get('security.token_storage')->getToken()->getUser();
        if ($request->files->get('file') instanceof UploadedFile) {
            $imagePath = $this->get('core_manager')->uploadProfileImagePost($request->files->get('file'), $entity);
            $img = new Image();
            $img->setPath($imagePath);
            $em->persist($img);
            $entity->setImage($img);
            $em->flush();
        }

        return new JsonResponse($imagePath);

    }