从Symfony2中的目录检索图像到视图

I have followed the upload tutorial provided in symfony2 cookbook and my question is now how to retrieve the file and to correspond to the records in the database...Thanks

If you followed this tutorial, you will notice that your object has a getWebPath() function. You can use this function to get a path that you can use on your web site to create a link to this document. For example, in twig:

<a href="{{document.getWebPath()}}">Document</a>

I have been able to implement both the upload and also editing of the uploaded file with reference to the entity but cannot be able to delete.Here is the method am using for delete in the controller.

public function deleteimageAction($id)
{
    $form = $this->createDeleteForm($id);
    $request = $this->getRequest();

    $form->bindRequest($request);

    if ($form->isValid()) 
    {
        $em = $this->getDoctrine()->getEntityManager();
        $entity = $em->getRepository('AcmeDemoBundle:Document')->find($id);

        if (!$entity) 
        {
            throw $this->createNotFoundException('Unable to find Document entity.');
        }
        $entity->removeUpload(); 

        //$em->remove($entity);
        $em->persist($entity);
        $em->flush();

    }

    return $this->redirect($this->generateUrl('viewimages'));
} 

Any help will be appreciated...