>
> Hi
>
> I am trying to force downloading a pdf file using media views.
> In my controller I added
>
> function download () {
>
> $this->view = 'Media';
> $params = array(
> 'id' => 'example.pdf',
> 'name' => 'example',
> 'download' => true,
> 'extension' => 'pdf',
> 'path' => APP . 'files' . DS,
> );
>
> $this->set($params);
>
> }
The only thing I see missing is 'mimeType'. Otherwise, it looks fine,
aside from the fact you're using hard-coded values (I assume this is
just for testing).
You do have an example.pdf file in the correct location? Check its
(and the directory's) permissions, also.
> Is there anything else I have to add or change because when I click the link
> it gives me the error that the requested address was not found on this
> server. It seems like it is looking for a view file for download.
It's tricky, as Cake emits a 404 when debug is set to 0 and there's
any kind of non-fatal error. But you need it set to 0 to use
MediaView.
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment