Hi!

It appears to me that my first attempt to send this message was blocked, so I'm 
resending (sorry if this message should finally appear twice in the 
mailinglist!).

I have trouble loading Office documents and pdf files through a action 
controller.
My idea was to use Zend_Controller_Action::_response and fill it with necessary 
information:


if (preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT']))
{
  $this->_response->setHeader('Cache-Control', 'no-store');
  $this->_response->setHeader('Cache-Control', 'no-cache');
  $this->_response->setHeader('Cache-Control', 'must-revalidate');
}

$this->_response->setHeader('Content-type', 'application/msword');
$this->_response->setHeader('Content-Length' , $size);
$this->_response->setHeader("Content-Disposition",
                            "inline; filename=" . $filename);

$data = file_get_contents($filename);
$this->_response->setBody($data);

This works perfectly for Firefox and IE 7.0.
Unfortunately, I have trouble with the same code under IE 6.0 and lower (and 
can't make all visitors upgrade :(   ). These browser versions don't use the 
Content-Disposition header to generate a filename for the file that would be 
opened in Word or Acrobat Reader. Afaik it instead uses the URI to generate the 
filename. So my idea was to create URIs like:

http://localhost/app/FileLoader/openfile/filename/myfile.pdf

with

- 'FileLoader' as the controller,
- 'openfile' as the action and
- 'filename' param of value 'myfile.pdf'

This almost works, a popup opens that asks me if I would like to open or save 
the file that is of type 'Adobe Acrobat Control for ActiveX'. Unfortunately, 
this file is named 'myfile_pdf' and when clicking 'open', I receive an error 
message.

My idea was that this might have to do with default routing I'm using (I tried 
ZF1.5.0 and svn trunk).

Do you have an idea what I might have to adjust to make the code safely open 
these documents in IE6?

Best regards,

Stephan

_________________________________________________________________________
In 5 Schritten zur eigenen Homepage. Jetzt Domain sichern und gestalten! 
Nur 3,99 EUR/Monat! http://www.maildomain.web.de/?mc=021114

Reply via email to