I don't think it's documented yet but you can use:

// full path + name
$form->picture->getFileName()

and

// just the path
$form->picture->getDestination()

to get info about the uploaded file.


On Oct 23, 2008, at 1:27 AM, andersl wrote:


to me this

"And file elements do not have a value until now due to security reasons."

means that getValue returns something "now".

so my question is now, when will getValue return something or is there
another way to get the path of the uploaded file?



andersl wrote:

So that means if I get the trunk right now and remove the rename filter
everything should be just fine?



thomasW wrote:

In trunk you don't have to add a empty rename filter.
And file elements do not have a value until now due to security reasons.

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

----- Original Message -----
From: "andersl" <[EMAIL PROTECTED]>
To: <fw-general@lists.zend.com>
Sent: Tuesday, October 21, 2008 9:18 PM
Subject: Re: [fw-general] Problems with Zend_Form_Element_File since
ZF1.6.2



Hi

I got the trunk from yesterday and even though I add the rename filter I still dont get any value from the getValue. The file gets uploaded but
the
getValue just dont return anything. I use addElements to get the element
on
the screen. Could this be the issue? My code looks something like this:
...
$this->setAttrib('enctype', 'multipart/form-data');
...
      //picture
      $picture = new Zend_Form_Element_File('picture');
$picture->setLabel('Picture')
->setRequired(true)
      ->setDestination('/var/www/images')
      ->addValidator('Count', false, 1)     // ensure only 1 file
      ->addValidator('Size', false, 1MB)
      ->addValidator('Extension', false, 'jpg,png,gif,jpeg')
      ->addFilter('Rename', array('/var/www/images', true))
      ; // only JPEG, PNG, and GIFs
...
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$this->addElements(array($id, $name, $picture, $submit))

and in my controller I have:

if (!$form->picture->receive())
{
print "Error receiving the file";
}

//$row->picture = $form->picture->getValue();
//$row->picture = $form->getValue('picture');

both getValue gives me nothing :(

Im looking forward to your reply :)

Anders

thomasW wrote:

As reply to an mail this has been sent on 15.Oct:
-----------------------------
Yes, this issue was added 7 hours ago and have already been fixed in
trunk
and branch.
To solve this shortly you can:

* Do not use addElement on the file element... the reason is that
getValue()
will be called on the file elements but they have no value and behave
false
in such a condition
or
* Add a empty rename filter by setting source and target the same value
------------------------------

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

----- Original Message -----
From: "drj201" <[EMAIL PROTECTED]>
To: <fw-general@lists.zend.com>
Sent: Monday, October 20, 2008 1:21 PM
Subject: [fw-general] Problems with Zend_Form_Element_File since
ZF1.6.2



I am trying to add a Zend_Form_Element File to a form... I am
extending
Zend_Form with my own class for reuse purposes. The problem is that
since
upgrading to ZF 1.6.2 my code no longer works.

Build element:

$this->addElement('file', 'logo', array(
          'label' => 'Logo',
...etc
      ));

Add to form using group decorator:

$this->addDisplayGroup(
          array('logo'), 'logodata',
          array(
              'legend' => 'Dealer Logo'
          )
      );

This results in the following error:

Warning: Exception caught by form: Unknown file Stack Trace: #0
demoapp/lib/Zend/Form/Element/File.php(357):
Zend_File_Transfer_Adapter_Abstract->getFilters('logo') #1
demoapp/lib/Zend/Form/Element.php(524):
Zend_Form_Element_File->getFilters()
#2 demoapp/lib/Zend/Form/Element.php(541):
Zend_Form_Element->_filterValue(NULL, NULL) #3
demoapp/lib/Zend/Form/Decorator/ViewHelper.php(201):
Zend_Form_Element->getValue() #4
demoapp/lib/Zend/Form/Decorator/ViewHelper.php(231):
Zend_Form_Decorator_ViewHelper- >getValue(Object(Zend_Form_Element_File))
#5
demoapp/lib/Zend/Form/Element.php(1905):
Zend_Form_Decorator_ViewHelper->render('') #6
demoapp/lib/Zend/Form/Decorator/FormElements.php(100):
Zend_Form_Element->render() #7 demoapp/lib/Zend/Form.php(2596):
Zend_Form_Decorator_FormElements->render('') #8 /Applicat in
demoapp/lib/Zend/Form.php on line 2616


Using the following manual approach works fine:

$element = new Zend_Form_Element_File('foo');
$element->setLabel('Upload an image:')
...etc

Any reason this has happened since upgrading to 1.6.2?

Thanks,
David
--
View this message in context:
http://www.nabble.com/Problems-with-Zend_Form_Element_File-since-ZF1.6.2-tp20067249p20067249.html
Sent from the Zend Framework mailing list archive at Nabble.com.




--
View this message in context:
http://www.nabble.com/Problems-with-Zend_Form_Element_File-since-ZF1.6.2-tp20067249p20097147.html
Sent from the Zend Framework mailing list archive at Nabble.com.






--
View this message in context: 
http://www.nabble.com/Problems-with-Zend_Form_Element_File-since-ZF1.6.2-tp20067249p20124593.html
Sent from the Zend Framework mailing list archive at Nabble.com.


Reply via email to