I have the setDestination in the Action Method
$logofield = $this->_advertiserCreateForm->getElement('logo');
$logofield->setDestination('usr/logos');
i guess thats where is get lost in the documentation..maybe i have it in the
wrong place.
Bob O wrote:
>
> I have been really struggling with this one. i have read and searched but
> still am unable to get it to work correctly.
>
> Im able to get the name of the image into the db..but I havent been
> successfull at getting the image itself to upload to my usr/logos dir..
>
> Please help..
>
> This is my controller
>
> **INIT**
>
> $config = new Zend_Config_Ini(APPLICATION_PATH .
> '/config/advertiserCreateForm.ini');
> $this->_advertiserCreateForm = new
> Zend_Form($config->reseller->advertiserCreate);
> $logo = new Zend_Form_Element_File('logo');
> $logo->removeDecorator('Label')
> ->setAttrib('size', '13')
> ->addValidator('Size', false, 102400) // limit to 100K
> ->setMaxFileSize(102400); // limits the filesize on the
> client side
> $this->_advertiserCreateForm->addElement($logo);
> $this->view->assign('advertiserCreate',
> $this->_advertiserCreateForm);
>
> **Action Method**
> public function createAdvertiserPostAction()
> {
> if ($this->getRequest()->isPost())
> {
> $values = $this->getRequest()->getPost();
> $logofield = $this->_advertiserCreateForm->getElement('logo');
> $logofield->setDestination('usr/logos');
>
> if ($this->_fonrootsReseller)
> {
> if
> ($this->_advertiserCreateForm->isValid($this->getRequest()->getPost()))
> {
> $id = $this->_id;
> $advertiser =
> $this->_fonrootsAdvertiser->createAdvertiser($values, $id);
> $this->_advertiserCreateForm->receive();
> $this->flash("Your Advertiser has been Setup", '',
> '/reseller/create-advertiser');
> }
> else
> {
> foreach ($this->_advertiserCreateForm->getMessages() as
> $messages)
> {
> foreach ($messages as $message)
> {
> $this->flash(("Invalid Data: $message\n"), 'error',
> '/reseller/create-advertiser');
> }
> }
> }
> }
> }
> }
>
> **MODEL**
> public function createAdvertiser($values, $resellerId)
> {
>
> // get "salt" for better security
> $configuration = Zend_Registry::get('configuration');
> $salt = $configuration->auth->salt;
>
> $password = $salt . $values['password'];
>
> //setup for logo upload
> $filename = $values['logo'];
>
> $now = time();
> $niceName = FonRoots_Utilities::toNiceString($values['advertName']);
>
> $advertiserData = array('id' => null,
> 'advertiser' => $values['advertName'],
> 'nice_name' => $niceName,
> 'contact_person_id' => $contactPersonId,
> 'location_id' => $locationId,
> 'reseller_id' => $resellerId,
> 'date_created' => $now,
> 'short_description' =>
> $values['shortDescription'],
> 'long_description' =>
> $values['longDescription'],
> 'url' => $values['advertiserURL'],
> 'logo_url' => $filename,
> 'date_created' => $now
> );
>
> $dbAdvertiser = new Advertiser();
> $dbAdvertiser->insert($advertiserData);
> }
>
-----
Bob Hanson
Web Developer
SLC, UT
--
View this message in context:
http://www.nabble.com/Zend_Form-Logo-upload-tp22490172p22506843.html
Sent from the Zend Framework mailing list archive at Nabble.com.