Wednesday, April 14, 2010

File Upload with Zend Framework

If you are using a more recent version of Zend Framework (i.e. 1.10), don't make the
same mistake that I have made at least three times now.

First, call isValid. THEN, call receive(). From what I can tell, there is a Validator on the file object, which verifies the existence of the file in the tmp folder. However, when you call receive(), the file is moved to the destination folder.

So, your code should look something like this:

if($form->isValid($this->getRequest()->getParams())) {

if ($form->name->receive()) {
// create success message here
// or create a Zend_Filter_File_Rename
}
}


File uploads in Zend has been a very challenging problem to me. I'd like to blame the documentation, but Thomas Weidner would not appreciate that very much.

Tuesday, March 2, 2010

Show Hidden Files in Zend Studio 7 (Mac)

I am not able to import my Aptana project into Zend Studio 7 because it is inside the folder /usr/local/ on my machine (Macintosh OSX), which is technically a hidden folder.

Although I have hidden files and folders visible in Finder, Zend's file browser does not show them.

I did find one Zend Studio setting under Preferences>Remote Systems>Files that allows you to "Show hidden files". But, guess what! That doesn't do diddlysquat for folders!

The solution that I am going to pursue is to move my project into the Sites folder, which is not hidden.

--Chris Baker