re: IE double download

From: Date: Mon, 13 Aug 2001 15:21:07 +0000
Subject: re: IE double download
Groups: php.general 
Request: Send a blank email to php-general+get-62450@lists.php.net to get a copy of this message
I read that IE first read the headers fully ( including the file ) and then ask it again for opening while Netscape read the file only once.
This description matches what I've seen. Here's what I've come up with that seems to work for IE and Netscape on Windows and Mac. //$y is the full pathname of the file ...
        $x = stat( "$y" );
        header( "Accept-Ranges: bytes" );
        header( "Content-Length: " . $x[7] );
        header( "Connection: close" );
        $a = basename( $y );
        if( strpos($a,':') )
            $a = substr( $a,0,strpos($a,':') );
        if( strpos($y,'.') )
            $z = substr( $y,strrpos($y,'.') );  // get suffix
        else
            $z = 0;
        if( $z )
            {
            if( strpos($z,':') )
                $z = substr( $z,1,strpos($z,':')-1 );
            else
                $z = substr( $z,1 );
            header( "Content-Type: " . FindMime($z) );	// FindMime is my function
            }
        else
            {
            header( "Content-Type: application/octet-stream" );
            }
        readfile( "$y" );
        exit;
-- Bill Rausch, Software Development, Unix, Mac, Windows Numerical Applications, Inc. 509-943-0861 bill@numerical.com

« previous php.general (#62450) next »