php - Image not moving to proper folder zend framework2 -


i started working on zend framework image upload.the code not showing errors image not moving proper destination.

public function uploadaction()     {         error_reporting(e_all);         ini_set('display_errors', 1);         $form = new uploadform();         $form->get('submit')->setvalue('add');         $request = $this->getrequest();         if ($request->ispost())          {             $profile = new upload();             $form->setinputfilter($profile->getinputfilter());              $nonfile = $request->getpost()->toarray();             $file    = $this->params()->fromfiles('fileupload');             $data = array_merge_recursive($request->getpost()->toarray(), $request->getfiles()->toarray());             //print_r($data);die;             //set data post , file ...             $form->setdata($data);              if ($form->isvalid())              {                   $favicon = $data['fileupload']['name'];                  $ext = pathinfo($favicon, pathinfo_extension);                  $faviconnewname = "_favicon." . $ext;                  $favadapter = new \zend\file\transfer\adapter\http();                  $favadapter->setdestination('public/img/upload'); //upload destination                  $favadapter->addfilter('rename', $faviconnewname, $favicon);                  if($favadapter->receive($favicon))                  {                      echo "suceess";                  }                  else                  {                      echo "failed";                  }                  die;             }         }         return array('form' => $form);     } 

the image not received , gives failed message.can solve problem.thanks in advance

you write "gives failed message" apparently goes wrong. should try find out , why... can guess information giving inside question.

if read zf2 documentation on file adapter class here can see adaper has getmessages method. might give insight on goes wrong:

$adapter = new zend\file\transfer\adapter\http(); $adapter->setdestination('public/img/upload');  if (!$adapter->receive()) {     $messages = $adapter->getmessages();     echo implode("\n", $messages); } 

this code snippet comes straight out of official docs!


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -