The following Zend Framework form isn’t working properly:
<?php
class Application_Form_Auth extends Zend_Form
{
public function init()
{
$this->setAttrib('enctype', 'multipart/form-data');
$this->setMethod('post');
$username = $this->createElement('text','username');
$username->setLabel('Username:')
->setAttrib('size',10);
$password = $this->createElement('password','password');
$password->setLabel('Password')
->setAttrib('size',10);
$file = new Zend_Form_Element_File('file');
$file->setLabel('File')
->setDestination('/data/uploads')
->setRequired(true);
$reg = $this->createElement('submit','submit');
$reg->setLabel('save');
$this->addElements(array(
$username,
$password,
$file,
$reg
));
return $this;
}
}
?>
The problem resides in:
->setDestination('/data/uploads')
When I remove this line from the code the form is working properly. I have the upload folder in /data/uploads and have permission set to 777 for the directory. How can I solve this? Thanks
Do you use any domain (With out localhost). if it is yes you should use data/uploads. The data directory should locate in public directory. If you have any domain you should use destination path with baseUrl.