Hi Gina-Marie,

Am Freitag, den 15.08.2008, 14:56 -0700 schrieb rollockg:
> I've been able to successfully upload a pdf file to my server, now I want to
> reverse the process. I just have no idea how to go about it using Zend
> Framework?

You do it in a very similar way as you would do it plain PHP: you send a
header, read the file, send the content of the file. So in a controller
it could looks something like this:

public function downloadAction()
{
    $this->getResponse()->setHeader('Content-Type: foo/bar');
    $filename = 
$this->sanitizeFilename($this->getRequest()->getParam('filename'));
    $this->getResponse()->appendBody(file_get_contents($filename));
}

Note: the sanitizeFilename()-method is not present. You must implement
something like this to not introduce security issues where people can
download your /etc/passwd or something similar. But preferably such
validation is done in your domain model.
If you have a model and such file is part of your model, it could
probably look like that:

public function downloadAction()
{
    $model = new YourDomainModel($this->getRequest()->getParam('filename'));
    $this->getResponse()->setHeader('Content-Type', $model->getType());
    $this->getResponse()->appendBody($model->getContent());
}

cu, Lars

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil

Reply via email to