completeamateur Posted December 1, 2008 Share Posted December 1, 2008 Why is the ZF so baffling? I'm trying to provide a facility to upload files. I have created an element within the form... $image = new Zend_Form_Element_File('image'); $image->setLabel('Photo') ->setAttrib('enctype', 'multipart/form-data') ->setRequired(false) ->setDestination('/upload/catalogue/images') ->addValidator('Count', false, 1) // ensure only 1 file ->addValidator('Size', false, 1024000) // limit to 1MB ->addValidator('Extension', false, 'jpg,png,gif'); // only JPEG, PNG, and GIFs ...and the controller consists of... if ($this->_request->isPost()) { $formData = $this->_request->getPost(); Zend_Debug::dump($_FILES); exit; ...but this just returns... array(0) { } i.e. no file is uploaded! I don't understand what I'm doing wrong. Any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/134997-solved-zf-je-suis-tres-confused/ Share on other sites More sharing options...
completeamateur Posted December 1, 2008 Author Share Posted December 1, 2008 I've just upgraded from ZF 1.5 -> ZF 1.7 and it now throws a form validation error... * The file '' could not be found * The file '' was not found Quote Link to comment https://forums.phpfreaks.com/topic/134997-solved-zf-je-suis-tres-confused/#findComment-703258 Share on other sites More sharing options...
awpti Posted December 1, 2008 Share Posted December 1, 2008 I can only tell you that ZF makes my eyes melt and brain explode. On a very random basis. I can't even determine from your code why it would throw the errors your seeing, let alone why it was previously kicking back an empty array. That's weird. It LOOKS fine.. Quote Link to comment https://forums.phpfreaks.com/topic/134997-solved-zf-je-suis-tres-confused/#findComment-703505 Share on other sites More sharing options...
Daniel0 Posted December 2, 2008 Share Posted December 2, 2008 Try something like this: if ($this->getRequest()->isPost() && $form->isValid($_POST)) { if (!$form->picture->receive()) { throw new Zend_Exception('The picture could not be uploaded.'); } else { Zend_Debug::dump($form->getValues()); } } Also, setAttrib('enctype', 'multipart/form-data') should be done on the form, not the element. Quote Link to comment https://forums.phpfreaks.com/topic/134997-solved-zf-je-suis-tres-confused/#findComment-703845 Share on other sites More sharing options...
completeamateur Posted December 2, 2008 Author Share Posted December 2, 2008 Daniel, I've made the modifications you have suggested and it looks as if we're half way there. I seem to have some permissions problems as it is throwing the following errors... Warning: move_uploaded_file(/Library/WebServer/Documents/bbusl/public/upload/catalogue/images/European Cup.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /Library/WebServer/Documents/library/Zend/File/Transfer/Adapter/Http.php on line 102 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/private/var/tmp/phpdDRdh9' to '/Library/WebServer/Documents/bbusl/public/upload/catalogue/images/European Cup.jpg' in /Library/WebServer/Documents/library/Zend/File/Transfer/Adapter/Http.php on line 102 Warning: move_uploaded_file(/Library/WebServer/Documents/bbusl/public/upload/catalogue/images/European Cup.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /Library/WebServer/Documents/library/Zend/File/Transfer/Adapter/Http.php on line 102 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/private/var/tmp/phpdDRdh9' to '/Library/WebServer/Documents/bbusl/public/upload/catalogue/images/European Cup.jpg' in /Library/WebServer/Documents/library/Zend/File/Transfer/Adapter/Http.php on line 102 I'm running Mac OS X, PHP 5.2.5, Apache 2.0. Any suggestions? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/134997-solved-zf-je-suis-tres-confused/#findComment-703919 Share on other sites More sharing options...
Daniel0 Posted December 2, 2008 Share Posted December 2, 2008 Yeah it sounds like permission problems. Try to chmod the upload dir recursively to allow write permissions for the httpd. Quote Link to comment https://forums.phpfreaks.com/topic/134997-solved-zf-je-suis-tres-confused/#findComment-703926 Share on other sites More sharing options...
completeamateur Posted December 2, 2008 Author Share Posted December 2, 2008 Yup, all sorted... no doubt that will throw another couple of hundred questions within the next 5 mins!! ;-) Out of interest, what's the default chmod (i.e. not 777)? Regards. P.S. Any suggestions re the complex query I posted?? Quote Link to comment https://forums.phpfreaks.com/topic/134997-solved-zf-je-suis-tres-confused/#findComment-703945 Share on other sites More sharing options...
Daniel0 Posted December 2, 2008 Share Posted December 2, 2008 Out of interest, what's the default chmod (i.e. not 777)? The default chmod depends on the umask. On my VPS the umask is 022, meaning that "write" (=2) will not be set for "group" and "other". This essentially means the default is 644 for files and 755 for dirs because the full access mode is 666 and 777 for files and dirs, respectively. If you care, then it's full & ~umask that'll be the default. Quote Link to comment https://forums.phpfreaks.com/topic/134997-solved-zf-je-suis-tres-confused/#findComment-703951 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.