2009年2月24日星期二

Re: [fw-mvc] Multiple file upload issues

I just tried this with the 1.7.5 tag instead of the trunk, and it worked...while that's all great, whatever happened to BC. I can understand if you wanna go ahead and beat the life out of the internal organs, but why mess with the API? 

On Tue, Feb 24, 2009 at 1:21 PM, Ed Lazor <edlazor@internetarchitects.biz> wrote:
Here's something that might help you.  It's an action that processes a
form with multiple file uploads.


    public function uploadAction() {

        $request = $this->getRequest();
        $form    = new FileForm();

        // process normal form
        if ($this->getRequest()->isPost()) {
                if ($form->isValid($request->getPost())) {
                        echo "Title = " . $form->getValue("Title") . "<br>\n";
                }
        }

        // process file uploads
            $adapter = new Zend_File_Transfer_Adapter_Http();
            $adapter->setDestination(ROOT_DIR . '/tmp/uploads');

            if ($adapter->isUploaded()) {
                echo "Processing Uploaded Files!<br>\n";

                        if ($adapter->receive()) {
 //                      $messages = $adapter->getMessages();
 //                      echo implode("\n", $messages);
                            $files = $adapter->getFileInfo();

                            echo "File name: Thumbnail<br>\n";
                            echo "File info:<br>";
                            echo "<pre>";
                            echo var_dump($files["Thumbnail"]);
                            echo "</pre>\n";

                            echo "File name: File<br>\n";
                            echo "File info:<br>";
                            echo "<pre>";
                            echo var_dump($files["File"]);
                            echo "</pre>\n";

 //                              foreach ($files as $file => $info) {
 //                                  if (!$adapter->isValid($file)) {
 //                                      print "Sorry but $file is not
what we wanted";
 //                                      continue;
 //                                  }
 //                                  echo "<br>\n";
 //                                  echo "File name = " . $file . "<br>\n";
 //                                  echo "File Info = <br>\n";
 //                                  echo "<pre>";
 //                                  echo var_dump($info);
 //                                  echo "</pre>\n";
 //                              }

                        }

            }

    }


 On Tue, Feb 24, 2009 at 9:34 AM, Abraham Block <atblock@gmail.com> wrote:
> I'm working off the latest version in the trunk, and I'm having some issues
> with multiple file uploads with Zend_Form_Element_File
> Consider the following:
>         $form = new Zend_Form();
> $element = new Zend_Form_Element_File('pictures');
> $element->setDestination(realpath(APP_ROOT . '/temp'))
>         ->setIsArray(true)
>         ->setMultiFile(2);
>
>         $form->addElement($element);
> $form->setAttrib('enctype', 'multipart/form-data');
> $form->addElement('submit', 'Submit');
> if ($this->getRequest()->isPost()) {
> if ($form->isValid($_POST)) {
> print_r($form->getElement('pictures')->getValue());
> }
> }
> The first file uploads fine but the second gives me a warning that looks
> something like this: Warning: move_uploaded_file(Array\{filename})
> For some reason its setting to the destination directory for the second file
> to an array for some reason.
>


没有评论: