Anyone having related issues should read here for details:
http://www.thomasweidner.com/flatpress/2009/04/17/recieving-files-with-zend_form_element_file/

Using two file transfer instances is really a no-go and introduces other problems when not being handled properly.

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

----- Original Message ----- From: "Ehask71" <[email protected]>
To: <[email protected]>
Sent: Friday, April 17, 2009 6:34 PM
Subject: Re: [fw-general] Zend_File_Transfer_Adapter_Http() Rename Filter issue



Just in case someone else has multifile issues :)

$upload = new Zend_File_Transfer_Adapter_Http();
$upload->setDestination(_IMGSOURCE_);
$i=0;
$mhash = md5($_SERVER['REMOTE_ADDR'].$_SERVER['HTTP_USER_AGENT']);

foreach ($upload->getFileInfo() AS $k => $info) {
if($info['name'] != ''){
$ext = pathinfo($info['name']);
$filename =
'image_'.$mhash.'_'.$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++;

$files[] = $filename;
}
}

$values = $form->getValues();

Then after I insert the Application into the db

$mid = $table->getAdapter()->lastInsertId();

if(is_array($files) && count($files) > 0){
// Add Photo to Db
$photo = new ModelPhotos();
foreach ($files AS $file){
if(file_exists(_IMGSOURCE_.$file)){
$data = array(
'modelid' => $mid,
'name' => $file,
'desc' => '',
'url' => '',
'hash' => $mhash,
'dateAdded' => new Zend_Db_Expr('NOW()')
);
$photo->insert($data);
try {
$resized = new App_Thumbnail(_IMGSOURCE_.$file);
$resized->resize( 600, 800);
$resized->save(_IMGSOURCE_.$file,80);
$resized->watermark(_IMGSOURCE_.$file);
$photo->_createThumbnail(_IMGSOURCE_.$file, _THUMBSOURCE_.$file,
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');
}
}
}
}

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

Reply via email to