Setting the name of a file in a download....

From: Date: Tue, 23 Apr 2002 05:59:45 +0000
Subject: Setting the name of a file in a download....
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-94117@lists.php.net to get a copy of this message
I am using the following code to create a downloader. It works, except that IE will just dump the contents to it's browser and Netscape 4 asks if I want to save it in a file called "blah.php".
    // File: blah.php
    if ( ! $fp = fsockopen ("www.steptwo.com.au", 80, $errno, $errstr, 30) )
    {
        echo "$errstr ($errno)<br>\n";
    }
    else
    {
        $userpass = "user:password";
        fputs ($fp, "GET /files/file.zip HTTP/1.0\r\n" .
                    "Host: www.steptwo.com.au\r\n" .
                    "Authorization: Basic " . base64_encode( $userpass ) . "\r\n" .
                    "\r\n");
        while ( $headerStr = trim( fgets( $fp , 3072 ) ) )
        {
            if ( strpos( $headerStr, ":" ) )
                header( $headerStr );
        }
        fpassthru( $fp );
    }
Is there any way to get it to save as a file called "file.zip"? Is there any header I can set? The headers it currently returns are: Date: Tue, 23 Apr 2002 06:02:36 GMT Server: Apache/1.3.12 (Unix) ApacheJServ/1.1.2 PHP/4.0.1pl2 FrontPage/4.0.4.3 mod_ssl/2.6.6 OpenSSL/0.9.5a Last-Modified: Tue, 23 Apr 2002 05:13:07 GMT ETag: "61b3e-ba-3cc4ed63" Accept-Ranges: bytes Content-Length: 186 Connection: close Content-Type: application/zip regs Brian White ------------------------- Brian White Step Two Designs Pty Ltd Knowledge Management Consultancy, SGML & XML Phone: +612-93197901 Web: http://www.steptwo.com.au/ Email: bwhite@steptwo.com.au

« previous php.general (#94117) next »