Download Files in IE6

I came across a rather interesting (and frustrating) problem with IE6. We serve some server-side pdf files and then just set the headers in PHP to make the browser load the file. Everything works fine except for IE6, but only if a standard user is installed for the Windows user account (i.e., not an administrator).

Since this is for the corporate environment, of course, all of their accounts are configured in this way. It is strange that the Content-Type is not recognized in the download dialog:

header( 'Pragma: public' );
header( 'Expires: 0' );
header( 'Cache-Control: must-revalidate, pre-check=0, post-check=0' );
header( 'Cache-Control: public' );
header( 'Content-Description: File Transfer' );
header( 'Content-Type: application/pdf' );
header( 'Content-Disposition: attachment; filename="xxx.pdf"' );
header( 'Content-Transfer-Encoding: binary' );
echo $content;
exit;

I also tried first writing the contents of the file to a temporary file so that I could also set Content-Lengthin the header, but that didn't help.

+3
source share
10

!

Content-Transfer-Encoding: binary

. HTTP , HTTP , . , X-Bits-Per-Byte: 8.

Cache-control: pre-check=0, post-check=0

, IE , . 0 , 0 . , Expires:0 must-revalidate , .

Content-Description: File Transfer

. . . X-Hi-Mom: I'm sending you a file!.

header( 'Cache-Control: must-revalidate, pre-check=0, post-check=0' );
header( 'Cache-Control: public' );

PHP . , .

Content-Disposition: attachment

( mod_rewrite index.php/fakefilename.doc - , Content-Disposition).

IE , ( "" , ), , , , IE .

, Cache-control:no-cache ( 20 ), .

NB: PHP , session.cache_limiter, HTTP-, none.

ini_set('session.cache_limiter','none'); // tell PHP to stop screwing up HTTP
+4

IE, ,

header( 'Expires: 0' );
header( 'Cache-Control: must-revalidate, pre-check=0, post-check=0' );

, , .

, .

, GZIP PDF , Acrobat, , .

, , , , -, PDF , -. , , , "" : p

+3

, ( Java-) IE6 PDF :

    response.setHeader("Content-Type", "application/pdf "; name=" + file.getName());
    response.setContentType("application/pdf");
    response.setHeader("Last-Modified", getHeaderDate(file.getFile());
    response.setHeader("Content-Length", file.getLength());

.

-, - IE6, , . , ... , SWF Flash. .

+1

, , , . , , symfony. , - :

public function download(sfResponse $response) {

        $response->clearHttpHeaders();
        $response->setHttpHeader('Pragma: public', true);
        $response->addCacheControlHttpHeader("Cache-control","private");        
        $response->setContentType('application/octet-stream', true);
        $response->setHttpHeader('Content-Length', filesize(sfConfig::get('sf_web_dir') .       sfConfig::get('app_paths_docPdf') . $this->getFilename()), true);
        $response->setHttpHeader("Content-Disposition", "attachment; filename=\"". $this->getFilename() ."\"");
        $response->setHttpHeader('Content-Transfer-Encoding', 'binary', true);
        $response->setHttpHeader("Content-Description","File Transfer");
        $response->sendHttpHeaders();
        $response->setContent(readfile(sfConfig::get('sf_web_dir') . sfConfig::get('app_paths_docPdf') . $this->getFilename()));

        return sfView::NONE;
}

IE6, IE7, Chrome, Firefox.

, -.

+1

, gzip . PDF ( ) , , .zip Internet Explorer, FireFox.

, zip ( , FireFox), .

PHP :

ini_set("zlib.output_compression",0);
0

Java ( Firefox 2 3, IE 6 7):

response.setHeader("Content-Disposition", "attachment; filename=\"" + file.getName() + "\"");
response.setContentType(getServletContext().getMimeType(file.getName()));
response.setContentLength(file.length());

. , gzip ( , ). ( , ). , .

0

, . , IE6, , ( , ) . .

0

SSL:

, ( Pragma). IE6 , , . .

2 , , , -.

0

, , , Pragma ist - "no-cache"

header( 'Content-type: application/octet-stream'); # force download, no matter what mimetype
header( 'Content-Transfer-Encoding: binary' ); # is always ok, also for plain text
0

Source: https://habr.com/ru/post/1696725/


All Articles