• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 810
  • Last Modified:

Unable to download file in Internet Explorer 8

Hi Experts,

I'm trying to start the download of a PDF file in Symfony. It works well using Firefox, Chrome, Opera, etc., but when I use Internet Explorer (7 + 8), I got the following error:
Unable to download file.pdf from domain.com.

Unable to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.

Open in new window

Needless to say, the website works everywhere else.

Here is the action in Symfony:
public function executeIndex(sfWebRequest $request)
{
    $filename = '/path/to/file.pdf';
    $response = $this->getResponse();
    $response->clearHttpHeaders();
    $response->addCacheControlHttpHeader('private, must-revalidate, post-check=0, pre-check=0');
    $response->setContentType('application/octet-stream', true);
    $response->setHttpHeader('Content-Transfer-Encoding', 'binary', true);
    $response->setHttpHeader('Content-Disposition', 'attachment; filename=' . $filename, true);
    $response->setHttpHeader('Content-Length', filesize($filename), true);
    $response->setHttpHeader('Last-Modified', gmstrftime("%a, %d %b %Y %H:%M:%S GMT", filemtime($filename)), true);
    $response->sendHttpHeaders();
    readfile($filename);
    return sfView::NONE;
}

Open in new window

I believe it's some header issue, but I've tried to enable/disable/switch them, without success.

Thank you for your help!
0
ChoobsTech
Asked:
ChoobsTech
2 Solutions
 
Sudaraka WijesingheWeb Application ProgrammerCommented:
Have you tried application/force-download instead of application/octet-stream?
0
 
Ray PaseurCommented:
One slight change in the design might overcome the problem in all browsers... Instead of trying to start the download, just write the PDF to a file on the server file system and give the client a link to start the download at the client's convenience.  Say something like, "Click here to download the PDF."  Most browsers are smart enough to tell the client if the PDF plug-in is missing.  HTH, ~Ray
0
 
James MurrellProduct SpecialistCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now