views:

215

answers:

2

Hello every body,

i m using zend form & create its elements using the code below.

// To create text box. $txt = $this->CreateElement('text', 'txtName'); $txt = $this->setLabel('First Name'); $elements[] = $element;

it works fine & it is posted firm form as well. But when i used the same technique to show a browse button, like.

// To Create Browse Button. $img = $this->CreateElement('file', 'imageId'); $img = $this->setLabel('Upload Image');

$elements[] = $element;

it does not work.

A: 

you should consult the manual for Zend_Form_Element_File.

I am not sure but it would make sense if the destination option would be a requirement.

$element->setLabel('Upload an image:')
        ->setDestination('/var/www/upload');

also you have to make sure the webserver have enough permission to write the file.

RageZ
+1  A: 

I guess this is a typo in your example and that you are actually using

$elements[] = $txt;
$elements[] = $img;

When you are using file elements you must not disable default decorators could it be that this is your problem?

Does it work if you are creating the file element like this:

$img = new Zend_Form_Element_File('imageId');
$img->setLabel('Upload Image');
$form->addElement($img);
Goran Jurić