Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 801017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:22:43+00:00 2026-05-14T23:22:43+00:00

I have a PHP script being served over https:// that is trying to push

  • 0

I have a PHP script being served over https:// that is trying to push a PDF file to the user. The problem that in Internet Explorer 6 (which unfortunately I still have to support) is not obeying the filename being set in the header. FireFox and IE7 are both working properly.

The file name keeps coming out as a random name with the correct extension. Example: “CAOTC5K3.pdf”, “CAXSIPXV.pdf” or “CA1OCVTX.pdf”

If I un-comment out the “Content-type” line, IE6 gives me an error, and tries to download the file inline with the name of the querystring that was passed to PHP.

<?php
//header( "Content-type: application/pdf" );
$filename = 'quickquote.pdf';
header( "Content-Disposition: attachment;filename=$filename" );
echo file_get_contents( "/example.pdf" );
die;
?>

I have tried wrapping the file name in quotes, adding a \n at the end of the header lines, adding header('Content-type: application/octet-stream');, adding header("Content-Type: application/force-download");

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T23:22:43+00:00Added an answer on May 14, 2026 at 11:22 pm

    I think you might need a space after attachment;:

    header("Content-Disposition: attachment; filename=$filename");
    

    If that doesn’t work, check out some of the points in this article, including:

    • On IE 6.0, things mostly work, but if you ALSO setup Cache-Control: no-cache, your suggested filename (and type!) will be IGNORED. A bummer if you have to choose between security and convienence. Of course, security wins.
    • On nearly all versions of IE, including 6.0, sometimes the browser will use the filename in the address bar instead of the Content-Disposition Header, and with IE5.5SP2 you’re expected to change the UseCDFileName registry key, see Q303750. This was fixed with IE6.0SP1.

    EDIT: Here’s the code I use, directly copied from my application’s source. Let me know if this works any better…

    function forceDownload($filename,$mime=false,$downloadName=false)
    {
        if(file_exists($filename) && is_readable($filename))
        {
            if(!$mime)      $mime = DFStdLib::determineMimeType($filename);
    
            if(!$expire)    $expire = DFStdLib::HOUR_IN_SECONDS;
    
            if(!$downloadName) $downloadName = basename($filename);
    
            header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($filename)).' GMT', true, 200);
            header('Cache-Control: no-cache',true);
            header('Pragma: Public',true);
            header('Expires: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT',true);
            header('Content-Length: '.filesize($filename),true);
            header("Content-Type: {$mime}",true);
            header("Content-disposition: attachment; filename=$downloadName",true);
            readfile($filename);
            exit();
        }
        else
        {
            header('HTTP/1.1 404 Not Found',true,404);
            echo "<html><head><title>Not Found</title></head><body>The file was not found.</body></html>";
            exit();
        }
    }
    

    Usage for your case would be:

    forceDownload('/example.pdf','application/pdf','quickquote.pdf');
    

    Also you’ll need to change DFStdLib::HOUR_IN_SECONDS to 3600 and write your own determineMimeType function, or delete that line and make the $mime argument required…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 490k
  • Answers 490k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try os.path.splitext it should do what you want. import os… May 16, 2026 at 9:59 am
  • Editorial Team
    Editorial Team added an answer Modern browsers would properly calculate the width of the shrinkwrapped… May 16, 2026 at 9:59 am
  • Editorial Team
    Editorial Team added an answer Nothing appears to be wrong with it at first glance.… May 16, 2026 at 9:59 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a php script im currently using that creates thumbnails based on a
I have a php script that I have used for years to force downloads
I have a problem with mysql connection. I have a php script which upload
I'm trying to set up a PHP script to read a handful of MySQL
I have a php script to show an image once their session is validated.
For a recent project, I have a PHP script running as a CLI-based daemon.
I have a page with a <script> tag in it pointing to a PHP
I'm trying to see what certain variables' values are in a C# .NET script
I have a page that needs to accept .csv files with no predefined layout.
I would like to generate a dynamic image from a script, and then have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.