By default, files are uploaded to the system temporary directory, which means you'll to either.
By default, files are uploaded to the system temporary directory, which means you'll to either : use move_uploaded_file to move the files somewhere else, or configure the directory to which Zend Framework should move the files ; your form element should have a setDestination method that can be used for that. For the second point, there is an example in the manual : $element = new Zend_Form_Element_File('foo'); $element->setLabel('Upload an image:') ->setDestination('/var/www/upload') ->setValueDisabled(true); (But read that page : there are other usefull informations).
1 +1 For configuring the destination in the form element and by pointing the manual. – Luiz Damim Dec 10 '09 at 13:17.
If you were to move the file to a public directory, anyone would be able to send a link to that file to anyone else and you have no control over who has access to the file. Instead, you could store the file in the DB as a longblob and then use the Zend Framework to provide users access the file through a controller/action. This would let you wrap your own authentication and user permission logic around access to the files.
You'll need to get the file from the /tmp directory in order to save it to the db: // I think you get the file name and path like this: $data = $form->getValues(); // this makes it so you don't have to call receive() $fileName = $data->file->tmp_name; // includes path $file = file_get_contents($fileName); // now save it to the database. You can get the mime type and other // data about the file from $data->file. Debug or dump $data to see // what else is in there Your action in the controller for viewing would have your authorization logic and then load the row from the db: // is user allowed to continue?
If (!AuthenticationUtil::isAllowed()) { $this->_redirect("/error"); } // load from db $fileRow = FileUtil::getFileFromDb($id); // don't know what your db implementation is $this->view->fileName = $fileRow->name; $this->view->fileNameSuffix = $fileRow->suffix; $this->view->fileMimeType = $fileRow->mime_type; $this->view->file = $fileRow->file; Then in the view: fileName. ". ".
$this->fileNameSuffix); header('Content-type: ". $this->fileMimeType. "'); echo $this->file;?
Thanks for talking about what to do once the user needs to download the file. I will be implementing a download action like you mentioned. – Andrew Dec 15 '09 at 3:34.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.