This is Crudcontroller  

```
            /**
             * This controller is designed for managing image file uploads.
             */
            class CrudController extends AbstractActionController 
            {
               /**
               * Entity manager.
               * @var Doctrine\ORM\EntityManager
               */
              private $entityManager;
              /**
                 * Image manager.
                 * @var Application\Service\PicManager;
                 */
              private $picManager;

                /**
                 * Constructor.
                 */
                public function __construct($entityManager, $picManager)
                {
                    $this->entityManager = $entityManager;
                    $this->picManager = $picManager;
                }

                /**
                 * This is the default "index" action of the controller. It displays the 
                 * Image Gallery page which contains the list of uploaded images.
                 */
                public function indexAction() 
                {
                    //$form = new AddForm();
                    //return new ViewModel(['form' => $form]);
                    // Get the list of already saved files.
            //$files = $this->picManager->getSavedFiles();
            $pic = $this->entityManager->getRepository(Pic::class)->findAll();
            return new ViewModel(['pic' => $pic]);
             }

                /**
                 * This action shows the image upload form. This page allows to upload 
                 * a single file.
                 */
                public function uploadAction() 
                {
                    // Create the form.
                    $form = new AddForm();
                    // Check whether this post is a POST request.
                    if ($this->getRequest()->isPost()) {
                        // Get POST data.
                        $data = $this->params()->fromPost();
                        // Fill form with data.
                        $form->setData($data);
                        if ($form->isValid()) {
                            // Get validated form data.
                            $data = $form->getData();}

                            // Use post manager service to add new post to database. 
                         $img_name = $data['file']['name'];
                         $url = $_SERVER['HTTP_SERVER'];
                         $seg= explode('/',$url);
                         $path = $seg[0].'/'.$seg[1].'/'.$seg[2].'/'.$seg[3];
                         $full_url = $path.'/'.'public'.'/'.'img'.'/'.$img_name;
                         $data['file']['tmp_name'] = $full_url;
                         $value = [
                      'name' => $data['file']['name'],
                      'avatar' => $data['file']['tmp_name'],
                                ];
                          $this->picManager->addNewImage($data);
                           return $this->redirect()->toUrl('http://projecting.localhost/images');
                    }
                return new ViewModel([
                        'form' => $form
                    ]);
                }

            }

```

This is my upload.phtml view file 

```
        <?php
        $this->headTitle('Upload a New Image');
        $form = $this->form;
        //$form->setAttribute('action',$this->url('crud',['action' => 'add']));

        //$form->get('submit')->setAttributes(['class'=>'btn btn-primary']);
        $form->prepare();
        ?>
        <h1>Upload a New Image</h1>
        <p>
            Please fill out the following form and press the <i>Upload</i> button.
        </p>
        <div class="row">
            <div class="col-md-6">
                <?= $this->form()->openTag($form); ?>
                <div class="form-group">
                    <?= $this->formLabel($form->get('name')); ?>
                    <?= $this->formElement($form->get('name')); ?>
                    <?= $this->formElementErrors($form->get('name')); ?>
                </div>
                <div class="form-group">
                    <?= $this->formLabel($form->get('avatar')); ?>
                    <?= $this->formElement($form->get('avatar')); ?>
                    <?= $this->formElementErrors($form->get('avatar')); ?>
                </div>        
                <?= $this->formElement($form->get('submit')); ?>
                <?= $this->form()->closeTag(); ?>
            </div>    
        </div>
        <div class="row">
        <table class="table table-hover">
          <thead>
            <tr>
              <th scope="col">Type</th>
              <th scope="col">Image Id</th>
              <th scope="col">Image Name</th>
              <th scope="col">Image Avatar</th>
            </tr>
          </thead>
          <tbody>
              <?php foreach($pic as $pic):?>
         <tr>
          <th> <h3><?= $this->escapeHtml($pic->getId()); ?>  </h3></th>
          <td></td>
          <td></td>
          <td></td>
        </tr>
             <?php endforeach; ?>
          </tbody>
        </table>
        </div>

```

I m getting this error 

> 
> Notice: Undefined variable: pic in C:\xampp\htdocs\form\module\Crud\view\crud\crud\upload.phtml on line 41 
> 
> 
> Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\form\module\Crud\view\crud\crud\upload.phtml on line 41
> 
> 
> 

how to defined the variable in zend framework ?  

 how to remove the error in zend framework of undefined varaible ?
i tried to solve the issue in zend framework but still not solved 
what is it showing undefined?
i tried to google the error but not got the answer
i have defined varaible in controller as well as manager also 
if more code is required i will help 
i tried to pass the variable from controller to view but no result
Thanks in advance