|
|||
|
Hello guys.
Today almost entire day investigating a problem with form validation with a file on it... The form defined in ini file, a file element defined in this way: Code:
form.elements.file.type = "file" form.elements.file.options.label = "Attach a file:" form.elements.file.options.attribs.class = "input" form.elements.file.options.validators.size = "1500000" form.elements.file.options.required = false Then there is such validation: Code:
if ( $request->isPost() ) {
if ( $form->isValid($_POST) ) {
Please help how I can get that uploaded file? I'm going crazy already ![]() |
|
|||
|
You should give your complete code, otherwise we can only speculate about possible problems.
What is $adapter ? What file do you upload ? How does the $_FILES array look like you mentioned ? Which release of ZF are you using ?
__________________
Greetings Thomas Weidner I18N Team Leader, Zend Framework http://www.thomasweidner.com |
|
|||
|
Still, what I said is true.
Without any additional information than just "it does not work", I can not help, nor can any other person. File uploads are really tricky therefor we need more informations than just the codelines. ![]()
__________________
Greetings Thomas Weidner I18N Team Leader, Zend Framework http://www.thomasweidner.com |
|
|||
|
Thomas,
$this->addElement('file','presentation', array( 'decorators' => $this->_standardElementDecorator, 'label' => $translate->_('presentation_photo').':', 'destination' => Bootstrap::$root.'/files/album/presentation', )); $this->getElement('presentation')->addValidator('Size', false, '10MB'); $this->getElement('presentation')->addValidator('Count', false, 1); $this->getElement('presentation')->addValidator('Extension', false, 'jpg,gif'); $this->getElement('presentation')->addValidator('ImageSize', false, array(60, 60, 640, 480)); $filter = new Zend_Filter_File_Rename(Bootstrap::$root.'/files/album/presentation/'.substr(md5(rand() * time()), 0, 16), true); $this->getElement('presentation')->addFilter($filter); Above is code from add form After I do $form->presentation->receive() in controller, the rename file is uploaded smoothly. However how could I retrieve that 'renamed' file name? P.S. $form->presentation->getValue(); ain't working ![]() Any help is much appreciated Thanks in advance Last edited by Directhr : 10-24-2008 at 08:49 AM. |
|
|||
|
Have you tried getFileName() ?
Because file elements don't have a value, wether in HTTP nor in Zend due to security reasons. Therefor getValue will (and should) return nothing until now. When we find a security-conform solution we will integrate it. ![]()
__________________
Greetings Thomas Weidner I18N Team Leader, Zend Framework http://www.thomasweidner.com |
![]() |
| Thread Tools | |
| Display Modes | |
|
|