Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-12-2008, 07:21 PM
Junior Member
 
Join Date: Oct 2008
Posts: 1
Default form validation with file element

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
The form displayed ok, as required.

Then there is such validation:

Code:
if ( $request->isPost() ) {
    if ( $form->isValid($_POST) ) {
And here before the isValid() call uploaded file accessible in temp dir, but after this call the file record presents in $_FILES array, but cannot be read with readfile($_FILES['file']['tmp_name']) or $adapter->receive().

Please help how I can get that uploaded file?
I'm going crazy already
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 10-12-2008, 08:38 PM
Member
 
Join Date: Aug 2008
Posts: 67
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-16-2008, 04:45 AM
Junior Member
 
Join Date: Sep 2008
Posts: 4
Default Same problem

I have the same problem here!

Some help would be much appreciated
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 10-16-2008, 05:28 AM
Member
 
Join Date: Aug 2008
Posts: 67
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 10-24-2008, 08:47 AM
Junior Member
 
Join Date: Sep 2008
Posts: 4
Default Rename filter

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 10-24-2008, 09:30 AM
Member
 
Join Date: Aug 2008
Posts: 67
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 10-25-2008, 12:33 AM
Junior Member
 
Join Date: Sep 2008
Posts: 4
Default Thanks

Thanks dude, for your prompt reply to save my Saturday morning misery :P

However I remembered I tried this getFileName() yesterday by my own, I did not work..

But wot'd hell, now it's ok. Thanks again
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 12:26 AM.