Zend Framework 2图像上传器问题

时间:2015-02-18 05:10:44

标签: php zend-framework zend-framework2 image-uploading

我在从Zend Framework2上传图片时遇到了问题它工作得很好但是现在它提出了一个问题"找不到文件"当我打印适配器,我需要有相同形式的2个文件上传器

这是我的控制器编码文件上传

            $adapter = new \Zend\File\Transfer\Adapter\Http();
            $files = $adapter->getFileInfo();
            $mediaFileHttpPostName = 'attr_image';
            $imageFile = $files[$mediaFileHttpPostName];



            $adapter->setDestination('./public/media');
            // $adapter->addValidator('Extension', false, array('jpge'), $mediaFileHttpPostName);

            $adapter->addFilter('Rename',
                array(
                    'target'=>  './public/media/'.$imageFile['name'],
                    'overwrite'=>true),
                $mediaFileHttpPostName);



            if (!$adapter->isValid()){
                $returnObject->errorMessage = $adapter->getMessages();
                $returnObject->result = 0;
            } else {
                try {
                    $adapter->receive($mediaFileHttpPostName);
                    $returnObject->result = 1;
                } catch (\Zend\Filter\Exception\InvalidArgumentException $e) {
                    $returnObject->errorMessage = $e->getMessage();
                    $returnObject->result = 0;
                }
            }

            $resizeObj = new Imageresize('./public/media/'.$imageFile['name']);
            $resizeObj -> resizeImage(400, 300, 'auto');
            $resizeObj -> saveImage($_SERVER['DOCUMENT_ROOT'] .'/uploads/attraction/main_image/'.$imageFile['name'], 100);

            $attra->setAttrImage($imageFile['name']);

0 个答案:

没有答案