As noted in the FAQ you are calling getValues() on the file element.
As the file itself is the value of the file element within ZF, this means that you receive the file by calling getValues().

All the code below getValues() will never get executed as there is no file anymore to receive. And as you have not added a rename filter before that call, the original file will be received unrenamed.

Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com

----- Original Message ----- From: "Ehask71" <cybertuff...@verizon.net>
To: <fw-general@lists.zend.com>
Sent: Thursday, April 16, 2009 9:08 PM
Subject: Re: [fw-general] Zend_File_Transfer_Adapter_Http() Rename Filter issue



Can anyone see why the Rename is not working with multifile upload?? I had
no issues with it 1.7 other than my misunderstanding on syntax. Everything
in the below code works perfectly except the Rename. So when that fails of course my thumbnail class doesnt fire since it looks for the renamed image.

Here is the multiFile
       $element = new Zend_Form_Element_File('file');
       $element->setLabel('Upload Images:')
       ->setDestination(_IMGSOURCE_);
       $element->addValidator('Count',false,array('min'=>1,'max'=>6))
       ->addValidator('Size',false,102400)
       ->addValidator('Extension',false,'jpg,gif,png');
       $element->setMultiFile(6);
       $this->addElement($element,'file');

Now my Controller code:

public function indexAction()
   {
   $form = new App_Form_ModelApp();

if (!$this->getRequest()->isPost()) {
$this->view->Form = $form;
return;
} elseif (!$form->isValid($_POST)) {
$this->view->Form = $form;
return;
}
$values = $form->getValues();

$data = array(
'name' => $values['name'],
!!! APPENDED TO SAVE SOME SPACE !!!
);
try {
$table = new ModelApps();
$table->insert($data);
$this->sendMail($data);
$mid = $table->getAdapter()->lastInsertId();

$upload = new Zend_File_Transfer_Adapter_Http();
$upload->setDestination(_IMGSOURCE_);
//$files = $upload->getFileInfo();
$i=0;
foreach ($upload->getFileInfo() AS $info) {
if($info['name'] != ''){
$ext = pathinfo($info['name']);
$filename =
'image_'.$mid.'_'.$i.'_'.date('Ymdhs').'.'.$ext['extension'];
$upload->addFilter('Rename', array('target' => _IMGSOURCE_.$filename,
'overwrite' => true));

if(!$upload->receive($info['name'])){
$this->view->messages = $upload->getMessages();
}
$i++;

// Add Photo to Db
$photo = new ModelPhotos();
$data = array(
'modelid' => $mid,
'name' => $filename,
'desc' => '',
'url' => '',
'dateAdded' => new Zend_Db_Expr('NOW()')
);
try {
$photo->insert($data);
$pid = $photo->getAdapter()->lastInsertId();
$resized = new App_Thumbnail(_IMGSOURCE_.$filename);
$resized->resize( 600, 800);
$resized->save(_IMGSOURCE_.$filename,80);
$resized->watermark(_IMGSOURCE_.$filename);
$photo->_createThumbnail(_IMGSOURCE_.$filename,
_THUMBSOURCE_.$filename, 100, 150, $q = 80);

}
catch (Exception $e)
{
$logger = Zend_Registry::get('logger');
$logger->warn("Image Insert Error - ". $e->getMessage());
$this->flash('There was a problem. Please Try
Again!','/modelapplication/error');
}

}
}
}
catch (Exception $e)
{
$logger = Zend_Registry::get('logger');
$logger->warn("Model App Insert Error - ". $e->getMessage());
$this->flash('There was a problem. Please Try
Again!','/modelapplication/error');
}
$this->flash('Thank You For Your
Submission','/modelapplication/success');

   }

--
View this message in context: http://www.nabble.com/Zend_File_Transfer_Adapter_Http%28%29-Rename-Filter-issue-tp21823191p23084437.html Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to