开发者

Is Zend_File_Transfer_Adapter_Http required to get info for uploaded file

I'm testing file upload with Zend_Form_Element_File. My form has this file element

    $file = new Zend_Form_Element_File('file');
    $file->setDestination(APPLICATION_PATH);
    $this->addElement($file);

In the action, I've seen examples that just use ->receive() to save the file

if($isPost()){
  if($formIsValid()){
     $form->file->receive(); 
  }
}

Other examples use Zend_File_Transfer_Adapter_Http() especially when trying to get file info. There's still receive() but it's on the http_adapter that they define in the action.

if($isPost()){
  if($formIsValid()){
     $upload = new Zend_File_Transfer_Adapter_Http();
     $upload->receive();
     $name = $upload->getFileName('file');
  }
}

My question: can I use $form->file->receive() like the first example and still get file details. I tried doing $thefile = $form->file->receive(); but $thefile turned out to be a boolean.

I basically want to use $form开发者_如何学Go->file->receive() without needing to define the Zend_File_Transfer_Adapter_Http in the action. Is it possible or no?


I think you can get detailed info in your action as follows:

            $fileElem = $photosForm->getElement('file');
            $adapter = $fileElem->getTransferAdapter();
            var_dump($adapter->getFileInfo());
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜