2

How to upload one file in multiple folders using zendframe work. When I tried image saving only in main folder, not saving in sub folders. Here is the code I had used in my controller.

 $apt    = new Zend_File_Transfer_Adapter_Http();
 $files  = $apt->getFileInfo();
 foreach($files as $file => $fileInfo) {
      $apt->addFilter('Rename', array('target' => 'images/practice/'.$fileInfo['name'],'overwrite' => true));
      $apt->addFilter(new Zend_Filter_File_Resize(array('width' => 500,'height' => 600  ,'keepRatio' => true,'directory'=>'images/practice/small/', 'overwrite'=>true)));
      $apt->addFilter(new Zend_Filter_File_Resize(array('width' => 300,'height' => 300,'keepRatio' => true,'directory'=>'images/practice/thumbs/', 'overwrite'=>true)));
 if ($apt->isUploaded($file)) {
            if ($apt->isValid($file)) {
                if ($apt->receive($fileInfo['name'])) {
                     $info = $apt->getFileInfo($file);
                }
             }
         }
         else{
         echo 'not uploaded<br>';
         }
    }

Please help me out, Thanks in advance.

user3668438
  • 165
  • 5
  • 18

1 Answers1

1

I think you should write your own filters for this. I haven't check the source of the current filters, but they all rename/move the file instead of copying it. If you would like create thumbnails of an image, you should probably extend Zend's resize filter and copy the result to the target directory instead of moving/copying it. It should not be very difficult to extend this class and change a few lines.

Once you did, you should use your own resize filter, instead of ZF's one. Watch the order in which you add the filters. If you rename the file first, I'm not a 100% sure if your own resize filter can determine the file's location.

M. Dekker
  • 131
  • 3