Re: [PHP Header] Right-Click Download in Firefox showing php filename

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks everyone. I looked into the Firefox browser forums/support and
found that the "Right-Click >> Save Link As" does not send the header
response, as it will take the file as-is. So in this example, it sees
the 'download.php' and then takes that as the default name. It then
starts the download of the file, which in turn gets the header
information and starts downloading the 'Setup.msi'... but now under
the name of 'download.php' -- Again to note in IE the Right-Click will
get the header information including the Content-Disposition and THEN
open the Save As window. In all browsers, the Left-Click works as
normal as it processes the header information.

My solution: With mod_rewrite under Apache. I know rewrite the
'download.php' file as default of 'ApplicationSetup.msi' -- So IF
Right-Clicked in FF, the user defaults the link with the proper
extension to Save As. Otherwise if Left-Clicked, the rewrite will run
the 'download.php' and then prompt with the correct MSI with version
number (as intended) : 'ApplicationSetup_v1_0.msi'

Otherwise with all the other header information, it works fine..  its
just the browsers that DO NOT get the header info on a Right-Click
Save As on objects, as they prompt to save in location BEFORE header
info is sought.

William Frankhouser
WilzDezign

On Mon, Aug 4, 2008 at 2:40 AM, David Otton
<phpmail@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
> 2008/8/4 Will <wilzdezign@xxxxxxxxx>:
>
>> I am trying to have users download a file named 'Setup.msi', however
>> under a PHP file with the sent header information, the default name to
>
>> $forcename = "ApplicationSetup_v1_0.msi";
>> $filename = "Setup.msi";
>>
>> header("Content-Type: application/force-download");
>> header("Content-Type: application/octet-stream; name=".$forcename);
>> header("Content-Type: application/octetstream; name=".$forcename);
>> header("Content-Transfer-Encoding: binary");
>> header("Content-Length: ".filesize($filename));
>>
>> @readfile($filename);
>
> Try a variation on this:
>
> header("Content-Type: application/x-msi");
> header("Content-Disposition: attachment;
> filename=\"ApplicationSetup_v1_0.msi\";" );
> header("Content-Transfer-Encoding: binary");
> header("Content-Length: " . filesize('Setup.msi'));
> readfile('Setup.msi');
>
> http://www.mhonarc.org/~ehood/MIME/rfc2183.txt
>
> content-disposition controls what the browser should do with the file
> you're sending (open it or save it).
> filename suggests what the file should be saved as on the local
> system, when downloading as an attachment
> content-type is the mime-type of the file you're sending
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux